M
|
Mack88DevClub member 5/9/2019 |
Hey Mark, |
![]() |
Pete K 5/9/2019 |
In the after init event ASP .NET Ver 9.8 c# looking to pull/get the DB connection string from the Web.Config or some other source. I tried the following in the event code // Addding the required Microsoft reference using System.Configuration; // then calling the appropriate method to get the connection string string cs = ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString; however this isn't working as the Microsoft reference needs to be added as part of the event prior to any code Any thoughts / feedback on how best to proceed most appreciated. Mark H. Big Tmber, MT - USA
|
![]() |
Admin 5/9/2019 |
H
|
heilmanmd author 5/9/2019 |
OK... here's all the gory details in PLAIN computer GEEK talk on how to do this... 1 First off , need to add a DLL to the CommonEvents.cs file in your ASP .NET Runner Project, i.e.
2 if using an IIS default and web "virtual directory" not wise, i.e. best to use C:\inetpub\wwwroot\.... 3 here is the code with lots of comments that is working, copy paste and have at it...
|
![]() |
Pete K 5/10/2019 |
I guess I don't understand why you think you need all that code. Sergey pointed out the easy solution. Basically, all you need is this line: System.Web.Configuration.WebConfigurationManager.ConnectionStrings["your_connection_string_name_here"]
|