简体   繁体   中英

Is necessary to include web.config file in IIS while hosting the ASP.Net Web application

I just want to know, it is really necessary to include web config file while we hosting the ASP.Net web application in IIS.

If Yes, Why and where it should be along with reason.

If No, Why and what is the reason.

Appreciate your assistance!

Kind Regards,

Web.Config Contains all the server configuration information (settings) related to each web application.

Read more here or the wiki page here

There should be at least 1 web.config in the root folder of your web application.

But if you want different settings for sub folders of your application you can place more web.config files in your sub folders, otherwise the sub folders will take root web.config by default .

The web.config on your site is come hierarchically to overwrite the default web.config that all ready used by asp.net and found on the config path inside the asp.net directory inside the windows folder.

In that default web.config on the high level many modules loaded by asp.net that needs to read a lot of parameters.

So many modules that by default loaded needs the web.config to properly work.

Also asp.net is check if the web.config exist and if you have write permission to it so he can handle it.

And to direct answer your question, in a complicate system there is not direct point to show you and tell "this modules need to read that parameter"... so the web.config is needed to run properly...

Its worth reading this article about optimizing web.config where the remove and the <clear /> is used to keep only the necessary modules for your site.

Here is a snipet from that article to show you that you need at least use it and remove the modules that you do not use

<httpModules>
         <!--<span class="code-comment"> Remove unnecessary Http Modules for faster pipeline --></span>
         <remove name="Session" />
         <remove name="WindowsAuthentication" />
         <remove name="PassportAuthentication" />
         <remove name="AnonymousIdentification" />
         <remove name="UrlAuthorization" />
         <remove name="FileAuthorization" />
</httpModules>

Also IIS use web.config when you setup your site - IIS store many information's about the site on web.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM