Link to home
Start Free TrialLog in
Avatar of vensali
vensaliFlag for India

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.Configuration
    Private connString As System.Configuration.ConnectionStringSettings

rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/WEBUI")    where WEBUI is project folder where webconfig resides.

        connString = rootWebConfig.ConnectionStrings.ConnectionStrings("Sqlserver")
        constr = connString.ConnectionString

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.
Avatar of jorge_toriz
Flag of Mexico image

Can you try with the following change?

Avatar of vensali
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vensali


I could solve the problem by giving   my web application name ( "/ App name")  hosted in iis in open configuration.