vensali
asked on
Reading from web configuration file
I can read connection string from webconfig file from visual studio from the below mentioned code
in login.aspx page
Private constr As String
Private rootWebConfig As System.Configuration.Confi guration
Private connString As System.Configuration.Conne ctionStrin gSettings
rootWebConfig = System.Web.Configuration.W ebConfigur ationManag er.OpenWeb Configurat ion("/WEBU I") where WEBUI is project folder where webconfig resides.
connString = rootWebConfig.ConnectionSt rings.Conn ectionStri ngs("Sqlse rver")
constr = connString.ConnectionStrin g
I created web deploy package and imported into localhost IIS 7. import application worked fine. when I tried to browse the login.aspx from IIS published folder I get the following msg
Server Error in '/KHWEB' Application. - KHWEB web application name in IIS7
Object reference not set to an instance of an object.
in login.aspx page
Private constr As String
Private rootWebConfig As System.Configuration.Confi
Private connString As System.Configuration.Conne
rootWebConfig = System.Web.Configuration.W
connString = rootWebConfig.ConnectionSt
constr = connString.ConnectionStrin
I created web deploy package and imported into localhost IIS 7. import application worked fine. when I tried to browse the login.aspx from IIS published folder I get the following msg
Server Error in '/KHWEB' Application. - KHWEB web application name in IIS7
Object reference not set to an instance of an object.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I could solve the problem by giving my web application name ( "/ App name") hosted in iis in open configuration.
OpenWebConfiguration("./WE