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

Sco*_*tes 8 asp.net custom-errors iis-7.5 iis-express asp.net-mvc-3

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

<authentication mode="Forms">
  <forms loginUrl="/" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

我以前customErrors的设置是这样的:

<customErrors mode="On" defaultRedirect="/ServerError">
  <error statusCode="404" redirect="/NotFound" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)

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

用于我的网站的AppPool Clr4IntegratedAppPool让我知道它不使用Classic.

为什么IISExpress如此依赖于system.webIIS 7.5使用system.webServer

Sco*_*tes 7

好吧,我尝试了一些不同的东西:

  • 改变existingResponsePassThrough作为注意这里

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

不!

  • 设置TrySkipIisCustomErrors= false在评论中所指出这里

Notta!

我最终得到它通过简单地改变工作existingResponseReplace.

  • 谁知道!

这就是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>
Run Code Online (Sandbox Code Playgroud)

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

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

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