为什么IIS Express使用<system.web>而不是<system.webserver>?</system.webserver> </system.web>

时间:2012-03-03 02:34:15

标签: asp.net asp.net-mvc-3 iis-7.5 iis-express custom-errors

使用的是Cassini,但已切换到IIS Express。我最初的想法是除了以下内容之外我可以删除所有<system.web>

<authentication mode="Forms">
  <forms loginUrl="/" />
</authentication>

我以前的customErrors设置如下:

<customErrors mode="On" defaultRedirect="/ServerError">
  <error statusCode="404" redirect="/NotFound" />
</customErrors>

当我切换到IISExpress时,我删除了这个customErrors元素。现在404不再重定向到我漂亮的“NotFound”页面了。

用于我网站的AppPool是Clr4IntegratedAppPool,这让我知道它不使用Classic。

为什么IISExpress如此依赖system.web而IIS 7.5使用system.webServer

1 个答案:

答案 0 :(得分:7)

我尝试了几件不同的事情:

  • 如上所述here

    existingResponse更改为PassThrough

    <httpErrors errorMode="Custom" existingResponse="Replace">

都能跟得上!

  • 如评论here
  • 中所述设置TrySkipIisCustomErrors = false

Notta!

我最终只需将existingResponse更改为Replace即可将其付诸实施。

  • 谁知道!

这就是system.webServer现在的样子:

<httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" path="/NotFound" responseMode="ExecuteURL" />
        <remove statusCode="500" subStatusCode="-1" />
        <error statusCode="500" path="/ServerError" responseMode="ExecuteURL" />
    </httpErrors>

为什么这个解决方案没有任何意义

  

替换 - 此值使自定义错误模块始终替换   自定义错误模块生成的文本的错误信息。如果   existingResponse设置为“Replace”,生成错误/异常   Asp.Net/WCF被IIS7错误取代。

http://blogs.iis.net/ksingla/archive/2008/02/18/what-to-expect-from-iis7-custom-error-module.aspx