Advantages of using web.config

Web.config is the main settings and configuration file for an ASP.NET web application. The file is a XML document that defines configuration information regarding the web application. In this article I will explain the main advantages of using the web.config file

Connection string settings

This section specifies a collection of database connection strings for ASP.NET applications and features.

connectionstring web config arvixe

Syntax:

<connectionStrings >
   <add />
   <clear />
   <remove />
</connectionStrings>

AppSettings

This element stores custom application configuration information such as database connection strings, file paths, XML Web service URLs, or any information stored in an application’s .ini file.

appsettings web config arvixe

Example:

<configuration>
   <appSettings>
       <add key="Application Name" value="MyApplication" />
   </appSettings>
</configuration>

Handlers settings

This enables ASP.NET to call the HTTP handler in order to service requests for resources that have the specified file name extension.

httphandlers web config arvixe

Example:

<configuration>
<system.web>  
<httpHandlers>     
<add verb="*" path="*.SampleFileExtension"          type="SampleHandler2 " />   
</httpHandlers> 
</system.web>
</configuration>

Custom Error configurations

With this we can set up custom errors. The customErrors element can be defined at any level of the hierarchy of application files.

customerrors web config arvixe

Example:

<configuration> 
<system.web>  
<customErrors defaultRedirect="GenericError.htm"  mode="RemoteOnly">     
<error statusCode="500"             redirect="InternalError.htm"/>   
</customErrors> 
</system.web>
</configuration>

Authentication and Authorization

Web.config allows us to establish who can access our application and specify which parts of our application.

authentication web config arvixe

Example:

<configuration>  
 <system.web>     
<authentication mode="Forms">        
 <forms name="401kApp" loginUrl="/login.aspx"/>    
 </authentication>    
 <authorization>      
   <deny users="?"/>    
 </authorization>  
 </system.web>
</configuration>

These are some of the features and advantages of the web.config file. It is very important to know that we can do. In this way we can control security levels, connections to databases, authorize users, customize and manage errors.

This concludes Advantages of using web.config

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez

Tags: , , , , , , , , , , , , , | Posted under ASP .NET 3.5, DotNet/Windows Hosting | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

Leave a Reply

Your email address will not be published. Required fields are marked *