Monday, 29 April 2013

How to add WEB.CONFIG File in ASP.NET


HOW TO ADD WEB.CONFIG FILE IN ASP.NET ?


This is the basic structure of web.config file . 




<?xml version="1.0"?>
<configuration>
  <appSettings></appSettings>
  <connectionStrings> </connectionStrings>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>



APPSETTINGS

   <appSettings>
      <add key="name" value="abc@domain.com" />
      <add key="password" value="password" />
  </appSettings>

CONNECTION STRING 


 <connectionStrings>
    <add name="con1"   
    connectionString="Server=servername;Database=databasename;Integrated Security=true;" />
  </connectionStrings>

SYSTEM.WEB

<system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>

Custom Error : 


 <customErrors mode="RemoteOnly"  defaultRedirect="ErrorPage.aspx">

      <error statusCode="403" redirect="default.htm" />
      <error statusCode="404" redirect="defaultPage.aspx" />
 </customErrors>