Cha*_*tes 5 error-handling asp.net-mvc custom-error-pages custom-errors asp.net-mvc-3
在我的web.config中的customErrors标记中,我指向一个控制器.在我的控制器中,我将重定向到由多个应用程序共享的外部错误页面.
<customErrors defaultRedirect="~/Error/ServerError" mode="On">
我的控制器:
public class ErrorController : Controller
{
public ActionResult ServerError()
{
return Redirect("/Systems/ASPNETErrorHandling/ErrorPage.aspx");
}
public ActionResult ErrorTest()
{
throw new Exception("testing error handling");
}
}
Run Code Online (Sandbox Code Playgroud)
我正在调用Error/ErrorTest来测试错误处理.但它总是重定向到Views/Shared/Error.cshtml而不是重定向到我指定的控制器.
如何让asp.net mvc遵守customErrors设置中的defaultRedirect路径?
UDPATE:我还使用ELMAH并重写HandleErrorAttribute在描述这个职位.我从.Net Reflector看到,基础HandleErrorAttribute将Error设置为视图.我不认为我可以做很多事情,重定向到Error.cshtml,或其他一些视图.
| 归档时间: |
|
| 查看次数: |
1042 次 |
| 最近记录: |