【发布时间】:2015-06-25 06:23:12
【问题描述】:
我使用Web.config 文件中的httpErrors 部分设置了自定义404 Not Found 错误页面。
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404"/>
<error statusCode="404" responseMode="ExecuteURL" path="/error/notfound"/>
</httpErrors>
当我导航到一个不存在的页面时,我得到以下 URL:
http://localhost/error/notfound?404;http://localhost/ThisPageDoesNotExist/
我不希望 URL 中的查询字符串,也不希望 301 或 302 重定向到未找到的页面。我怎样才能做到这一点?也许使用 URL 重写?
【问题讨论】:
-
尝试将 responseMode 更改为
Redirect而不是 ExecuteURL。 -
这会导致重定向。我更喜欢 ExecuteURL 所做的重写。
标签: c# asp.net .net asp.net-mvc asp.net-mvc-5