ASP.NET MVC 4 - Exception Handling Not Working

前端 未结 4 1474
执念已碎
执念已碎 2020-12-30 09:34

When an error occurs in my ASP.NET MVC 4 application, I would like to customize a view for the user depending on the type of error. For example, page not found or an except

4条回答
  •  梦谈多话
    2020-12-30 10:16

    Try adding the following attribute to the customErrors tag:

    defaultRedirect="Error"
    

    This explicitly defines to which view MVC should redirect the user when the error is thrown and no view is specified by default in the attribute. This will of course only work if Error.cshtml exists in the Shared views folder.

提交回复
热议问题