Mos*_*afa 10 asp.net web-config custom-errors iis-7.5
在我在共享主机提供程序中发布的ASP.NET 3.5网站中,我已经配置了我的web.config文件,如下所示:
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="AccessDenied.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
Run Code Online (Sandbox Code Playgroud)
如果不存在(如"www.example.com/NotExistPage.aspx")的用户请求的页面,因为我们预计用户会被重定向到FileNotFound.htm页.
但是如果用户请求某个地址,例如:"www.example.com/NotExistDirectory"而没有.aspx扩展名,则用户将遇到IIS 7.5错误页面:
HTTP错误404.0 - 未找到您要查找的资源已被删除,名称已更改或暂时不可用.
已淘汰的错误信息:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://www.example.com:80/NotExistDirectory
Physical Path D:\Websites\example\example.com\wwwroot\NotExistDirectory
Logon Method Anonymous
Logon User Anonymous
Run Code Online (Sandbox Code Playgroud)
这是一个黄页,不是用户友好的,我们没想到.
我想知道在webconfig中设置customeError不支持这种类型的地址吗?如何防止用户看到此黄页.
编辑: 感谢大卫的回答,但我找到了实际的原因和正确的解决方案.请看我的答案.
小智 12
@Mostafa:我遇到了同样的问题.我发现可以通过在web.config文件中添加以下内容来解决:
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/MyErrorPage.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13073 次 |
最近记录: |