2012-10-02 95 views
0

錯誤頁未顯示。以下是我的配置。錯誤頁未顯示

[HttpGet] 
public ActionResult Index(string name) 
{ 
throw new ArithmeticException(); 
} 

//Handle Error attribute 
public override void OnException(ExceptionContext filterContext) 
{ 
//logging 
filterContext.ExceptionHandled = true; 
base.OnException(filterContext); 
} 

<customErrors mode="On" defaultRedirect="~/Error"> 
     <error statusCode="404" redirect="~/Error/NotFound"/>  
</customErrors> 

我已經把「錯誤」和「錯誤」文件夾「NOTFOUND」的意見。但是,如果我輸入無效的網址,則會顯示「Notfound」視圖。但是對於算術例外,默認錯誤頁面沒有得到顯示,只有空白頁面以相同的URL顯示。你可以請任何人建議。

回答

0

我不確定,但是,如果你設置filterContext.ExceptionHandled = true;,那麼錯誤處理程序將不會將您重定向到錯誤頁面。所以請嘗試刪除它。

+0

謝謝。是的,那是缺少聲明。 – Sunny