且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET MVC 4 404错误处理不点火

更新时间:2023-02-15 22:23:37

阿拉法特的链接导致我这似乎工作的一个答案。在web.config文件中的 部分中,添加:

Yasser's link led me to an answer which seems to work. In the web.config file section, add:

   <httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
 </httpErrors>

您可以创建此路径的路由器和控制器,而这一切似乎工作。难道真的那么简单吗?

You can then create a router and controller for this path, and it all seems to work. Is it really that simple?