2011-02-07 30 views
0

我想跟着一篇關於自定義錯誤句柄的文章。我設置了我的控制器,視圖和全局文件。當我導航到Error/HttpError時,我看到了我的頁面。但是,當我嘗試在我的控制器之一中拋出一個新的異常時,我的任何錯誤代碼都不會觸發或重定向到任何地方,應用程序on_error也不會觸發。在MVC中自定義錯誤處理的問題

這給了我這樣的:

Error handler test 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ApplicationException: Error handler test 

Source Error: 

Line 275:  public ActionResult Website(RerModel model) { 
Line 276: 
Line 277:   throw new ApplicationException("Error handler test"); 
Line 278: 
Line 279:   var step = "Website"; 

我必須失去了一些東西?

+0

我的錯誤視圖位於稱爲錯誤的另一文件夾內的查看文件夾下。我是否需要以某種方式來觸發我的東西開火?我只是猜測? [的HandleError(ExceptionType = typeof運算(ApplicationException的),查看= 「錯誤」)] – 2011-02-07 20:27:51

回答

0

我認爲問題是你已經把視圖放在一個名爲「Error」的文件夾中。我認爲你需要將它移動到Shared(或特定於控制器的文件夾)。默認情況下,MVC不會在錯誤視圖中查找名爲「Error」的文件夾。