Roh*_*est 8 iis-7 asp.net-mvc-3
我有一个简单的ASP.NET MVC 3网站在IIS 7.0中托管,并且很难显示404.13 http状态代码的自定义http错误页面.
我的Web.Config中有以下配置
<system.web>
<httpRuntime maxRequestLength="2048"/>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<clear/>
<error statusCode="404" subStatusCode="-1" path="/home/showerror" responseMode="ExecuteURL" />
<error statusCode="404" subStatusCode="13" path="/home/showerror" responseMode="ExecuteURL" />
</httpErrors>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576"/>
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
当我导航到不存在的页面时,我的错误页面会正确呈现.但是,如果我上传的文件大于1MB,我会收到一个空的404响应.网址永远不会被执行.如果我将responseMode更改为Redirect,则会正确重定向用户.
小智 3
由于配置系统的锁定功能,自定义错误很可能不会显示。尝试以下命令来解锁:
%windir%\System32\inetsrv\appcmd unlock config -section:system.webserver/httperrors
Run Code Online (Sandbox Code Playgroud)
经过几天的使用 RequestFilters 和 CustomError 页面,它终于对我有用了。
归档时间: |
|
查看次数: |
4845 次 |
最近记录: |