Topic: Web.Config
Share/Save/Bookmark
Using Web.Config file
 
To set values in the web.Config file and call from application do the following:
1. Add the item to the Web.config file (Be sure to put this after the </system.web> element
      <appSettings>
            <add key="HelpAppConnString" value="server=DEV-100\SQLEXPRESS;Integrated Security=SSPI;database=HelpApp" />
      </appSettings>
2. From the class you want to call it from, add the namespace call
      using System.Configuration;
3. Assign the value or use it directly in your code
      _HelpAppConnectionString = ConfigurationSettings.AppSettings["HelpAppConnString"];
 
To set authorization
    <authorization>
      <!-- THIS DENIES ACCESS TO ANONYMOUS USERS -->
      <deny users ="?" />
      <allow users = "*" />
    </authorization>
 
To set authentication
    <authentication mode="Forms">
      <forms name=".ASPXFORMSDEMO" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
    </authentication>
    <!--authentication mode="Windows" /-->