我已經開始在VS10的MVC 3模板項目和修改的global.asax.cs這樣:HandleErrorAttribute不工作
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute { ExceptionType = typeof(DivideByZeroException), View = "DivideByZeroException", Order = 1 });
filters.Add(new HandleErrorAttribute { View = "AllOtherExceptions", Order = 2 });
}
到Web.config中我加:
<customErrors mode="On">
然後創建相應的視圖,並最終添加了DivideByZero-throw到其中一個動作。
結果:呈現AllOtherExceptions視圖。
聽起來像你有案例,恐懼!既然Darin確實解決了我的問題,那麼你必須用upvotes來對付這個問題。 – Martin
感謝你 - 應該是答案! –
更改了答案... – Martin