ASP.NET Technology

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.

Also Read :  javascript Manage cookies setcookie and getcookie

Web.configue in asp.net

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.

Also Read :  PHP Multiple images upload using jQuery Ajax

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

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.

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

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

Authentication

It describe possible value for Authentication.

<authentication mode="[Windows|Forms|Passport|None]"> 
   <forms>...</forms>
   <passport/>
</authentication>

Authorization

It describe possible value for Authorization.

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

Caching

It describe caching related setting.

Also Read :  CodeIgniter JQuery Ajax Request Example

<caching>
   <cache>...</cache>
   <outputCache>...</outputCache>
   <outputCacheSettings>...</outputCacheSettings>
   <sqlCacheDependency>...</sqlCacheDependency>
</caching>

CustomErrors

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. . ./>
</customErrors>

Deployment

It defines configuration settings used for deployment.

<deployment retail="true|false" />

Read :

Summary

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 Pakainfo.com 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.