Online Training for MVC Web Designing Development, MS SQL, Digital Marketing

Web.config file in Application

Web.Config in Application is a human-readable XML file, that you can open and edit with any simple text editor, Web.Config file contain configuration information of application, when you create a application a default Web.Config will be added in root of your application.

Using Web.Config in

Web.Config contain configuration information for a particular Application, but in hierarchy there another file called Web.Config, that contain configuration information of all application on that machine.
\WINNT\Microsoft.NET\Framework\[Framework Version]\CONFIG\machine.config
To make any changes in that file you need to have system level permission.

Now we talk about only Web.Config, while developing application the file will reside in root of your app, and while deploying on IIS, the file will be at the root of virtual directory.

Whenever you make any changes in Web.Config settings the application or the service will be automatically restarted, even a single letter changes will take the effect.
The top tag in web.config is configuration
<configuration> ... </configuration>

Here we discuss some of the important tags, which you change very often in your application

appSettings in web.config

You can add any number of key-value pair in this section
<add key="webpages:Version" value="" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="TestKey" value="TestValue"/>

appSettings is the section where you, you can add a new key-value, then retrieve the same in your application using ConfigurationManager.AppSettings

customErrors in web.config

If you want to implement custom error page to display user-friendly messages for any unhandled application error, then you can specify different page for different error code.
<customErrors mode="Off" defaultRedirect="~/error">
<error statusCode="404" redirect="~/error/page404" />
<error statusCode="500" redirect="~/error/page500" />
Custom configuration details in web.config
In this section of web.config you can add all Custom configuration details, please read the complete article on how to implement configuration framework in application
<sectionGroup name="CustomSetting">
<section name="SystemSettings" type="SystemHandler,WebTrainingRoom" />
<section name="BusinessSettings" type="BusinessHandler, WebTrainingRoom" />
Hope now you got the idea of how to work with web.config in application

Name Email Website
Web.config file in Application

Group Training