ASP.NET MVC Web Configuration File web.config

ASP.NET MVC Web Configuration File web.config

Today, We want to share with you ASP.NET MVC Web Configuration File web.config.
In this post we will show you ASP.NET – Configuration, hear for ASP.NET Web Configuration File we will give you demo and example for implement.
In this post, we will learn about Difference between Machine.config and web.config with an example.

All About Web.configue File

What is web.config file?

The configuration file is employed to manage varied settings that outline a website. The settings are kept in XML files that are separate from your application code so it can be changed without affecting the code. Typically a website contains one web.config file which is located in the root directory. However, your website may have multiple web.configue to manage setting at a different level.

Web.configue in

Visual Studio generates a default web.config file for each project. An application can execute without a web.config file, however, you cannot debug an application without a web.config file.

Usage of configuration file

ASP.NET Configuration system is used to manage and control the properties and behaviors of various aspects of ASP.NET applications. Configuration files help you to manage the many settings related to your website. Each file is an XML file (with the extension .config) that contains a set of configuration elements. Configuration information is stored in XML-based text files.

Benefits of XML-based Configuration files

ASP.NET Configuration system is extensible and application specific information can be stored and retrieved easily. This file is human readable.Any changes made in this file do not require the restart of a web server. ASP.NET automatically detects the changes and applies them to the running ASP.NET application.

You can use any standard text editor or XML parser to create and edit ASP.NET configuration files.

Also Read This 👉   full stack developer salary - 10 Steps to Becoming a Full Stack Developer

What Web.config file contains?

Web.configue file store several settings about web application. Some commonly used settings are listed below.

  • Error Handling
  • Caching settings
  • Database connections
  • Security
  • Session States

Some simple setting of web.configue looks like below.

      <add name ="DBCS"
           connectionString ="server=MyServer;database=ERP;
           uid=admin;[email protected]"/>

Now I will explain some commonly used setting of web.configue


It describe possible value for Authentication.

<authentication mode="[Windows|Forms|Passport|None]"> 


It describe possible value for Authorization.

   <allow .../>
   <deny .../>


It describe caching related setting.



This setting specify action that are neede when any exception arise in application. We can also set default page which will be display when exception occure in the system.

<customErrors defaultRedirect="url" mode="On|Off|RemoteOnly">
   <error. . ./>


It defines configuration settings used for deployment.

<deployment retail="true|false" />

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about ASP.NET Web Configuration File.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.