Wednesday 30 January 2013

what is web.config in ASP.NET ? ?

Hi all,

This is my first Article in my blog so please apologize for my english and if i convey anything
wrongly tell me

The time you start developing web application from that moment to until you finish your application
web.config file plays a major role for securing your application and also it handles all the
requirements at the application level but we must understand what we will do by means of
web.config file.

We must Remember the fallowing when we think about web.Config

> Web.config stored in XML format which makes us easier to work.
> We can have any number of web.config files for an application .Each web.config files
    applies their settings to thier own directory
> It inherit form the folder location "systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Web.config location" 
>IIS is configured in such way that it prevent the web.config file from browser access.
  
see Bellow the hierarchy of wen.config

<configuration>

        <configSections>
            <sectionGroup>
            </sectionGroup>
        </configSections>

        <system.web>
        </system.web>

        <connectionStrings>
        </connectionStrings>

        <appSettings>
        </appSettings>
        

</configuration>
 
 
So,for web.config file have the root element configuration tag,Each element 
can have any number attribute and child elements.

Let me Discuss some General Configuration settings in web.config file
 
<system.web>

The most common thing we work in configuration hierarchy is system.web.

<system.web
        <assemblies>
<add assembly="System, Version=1.0.5000.0, Culture=neutral/>
 </assemblies>

</system.web>
 
Page Settings 

Page settings is used for the general settings of all the pages, we can
set the general settings like sessionstate,viewstate,buffer, etc.,
 
<pages buffer ="true" styleSheetTheme="" theme ="Acqua"
              masterPageFile ="MasterPage.master"
              enableEventValidation="true"> 
 
Custom error Settings 

By using this we can configure the application level errors in these 
section.
 
<customErrors defaultRedirect ="Error.aspx" mode ="Off">
   <error statusCode ="401" redirect ="page.aspx"/>
</customErrors> 


Here we have default redirect and mode attribute which specifies 
the default redirect page and on/off mode respectively
 
 redirecting the default page depends upon the error status code .
 
400-bad request
401-unauthorized
404-not found
408-request time
 
By using web.config file we can give authentication,autorization,membership,
provider,role,profile 



 


 
 



 

 
 





No comments:

Post a Comment