使用的是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
?
答案 0 :(得分:7)
我尝试了几件不同的事情:
如上所述here
将existingResponse
更改为PassThrough
<httpErrors errorMode="Custom" existingResponse="Replace">
都能跟得上!
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