我已经设置了自定义404并且它有效。但是当我尝试访问一些不存在的文件时,它显示了很好的'ASP.NET 404.0错误页面。
我尝试添加<error statusCode="404.0" redirect="/notfound/?" />
,但由于statusCode
应为整数,因此无效。
http://localhost:123/das/dsagfdsa
将重定向到http://localhost:123/notfound/?
http://localhost:123/das/dsagfdsa.png
会留下并显示404.0
错误。
<customErrors mode="On" redirectMode="ResponseRedirect" defaultRedirect="/notfound/?">
<error statusCode="404" redirect="/notfound/?" />
</customErrors>
如何确保它不仅会在错误的网页请求中重定向到/notfound/
,还会在错误的文件请求中重定向到<{p}}?
答案 0 :(得分:1)
您必须在IIS中进行配置。默认情况下,只有特定文件将通过ASP.NET框架路由,否则IIS将处理它(配置如下面IIS的“错误页面”部分所示)。
或者,您也可以将ASP.NET配置为处理其他文件类型。有关详细信息,请参阅Handler Mappings。