Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.webServer and System.web sections of web.config

What is point to have two separate sections for defining error documents in web.config?

<system.webServer>
...
   <httpErrors errorMode="Custom">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="/ErrorPage_404.aspx" responseMode="ExecuteURL" />
   </httpErrors>
...
</system.webServer>

and

<system.web>
...
   <customErrors defaultRedirect="/Forms/Errors/Error.aspx" mode="On">
      <error statusCode="404" redirect="/ErrorPage_404.aspx" />
   </customErrors>
...
</system.web>

If I remove first section, IIS7 will not show error pages. If I remove second one, my VS debugger will not show error pages.

like image 692
Riz Avatar asked Aug 17 '11 07:08

Riz


People also ask

What is System webServer in Web config?

webServer> element specifies the root element for many of the site-level and application-level configuration settings for Internet Information Services (IIS) 7 in the ApplicationHost. config file, and contains configuration elements that define the settings used by the Web server engine and modules.

What is Web config file in IIS?

The web. config is a file that is read by IIS and the ASP.NET Core Module to configure an app hosted with IIS.

What is Web config used for?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).

What Web config file contains?

web. config file is an XML-based configuration file used in ASP. NET-based applications to manage various settings that are concerned with the configuration of our website. In this way, we can separate our application logic from configuration logic.


1 Answers

I always thought that system.web applied to IIS6 and below, while system.webServer applied to IIS7+, but actually it seems that the real answer is that system.web is for .aspx / .asp pages through its handler mapping, and everything else goes through system.webServer.

Have a look at this webpage for a pretty clear explanation.

like image 182
Henry C Avatar answered Oct 14 '22 03:10

Henry C