Problem With Custom Error Handling In MVC
I am trying to follow an article about custom error handle. I set up my controller, view, and global file. When I navigate to Error/HttpError I see my page. But when I try to throw a new exception inside one of my controllers none of my error code triggers or redirects me anywhere, nor does the application on_error fire.
It just gives me this:
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("Er开发者_如何学JAVAror handler test");
Line 278:
Line 279: var step = "Website";
I must be missing something?
I think the problem is that you have put the View in a folder called "Error". I think you need to move it into Shared (or a controller-specific folder). MVC does not by default look in a folder named "Error" for error views.
精彩评论