2011-06-21 46 views
0

我嘗試MVC3異常處理,並與下面的測試代碼來:MVC3異常處理和的customErrors問題

public class HomeController : Controller { 
    public ActionResult Index() { 
     throw new ArgumentException(); 
     return View(); 
    } 
} 

我控制器勢力拋出的異常,並在我的web.config

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

我已經創建了另一個控制器到服務器ErrorHandler/Index和ErrorHandler/NotFound請求。

隨着我的測試,我可以看到404代碼可以被捕獲,但500代碼已被完全忽略。

我的代碼有什麼問題嗎?從RegisterGlobalFilters方法在Global.asax

filters.Add(new HandleErrorAttribute()); 

感謝 哈迪

回答

3

刪除以下行。