ASP.NET- Web.config

XML files In general holds the settings of a website. One web config with one application although application may contain many other configuration files.
Separated from the application if you are making changes into web.config you need not to restart webserver(IIS).
IIS take care that web.config should not be accessible from any other browsers.
Important settings that can be stored in web.config:
# Database Connections: using section
Access from code by using ConfigurationManager.ConectionStrings[“..”]
Project must reference the System.Configuration assembly.
# Caching settings.
# Session States.
# Security.

Few important tags of web.config:
– Parent tag
– Can reside under configuration section or inside Location tag.

Child elements to configure different modules of system.web:
<compilation> : Use to specify target framework and to add assembly from global assembly cache(GAC).  From 2012 VS onward this section comes by default in web.config.
<pages> : Can use to do page level changes like Session, buffer, viewstate Also by using available attributes we can specify Masterpage file and themes.
<customErrors> : To configure application level custom errors Mode=On/Off/RemoteOnly.
ON- custom errors shown to remote client or to local client.
OFF- show detailed ASP.NET error.
RemoteOnly- Custom errors shown to remote client and detailed asp.net error to local client.
<sessionState> : Have three modes: InProc, StateServer, SQLServer.
<authentication> : Available modes: Windows(default), Forms, Passport, None.
<authorization> : Controls client access to URL resources. allow/deny users,roles,verbs.
<globalization> : Helps to make it appropriate for many different cultures.

Other important tags:
<appSetting>: Hep us to store application setting information.
<configSections> : Helps to create own custom configuration sections.

Note* Although IIS take care of securing web.config, we can also encrypt some of the sections of web.config.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s