Error Controller

Jan 9, 2011 at 6:56 AM
Edited Jan 9, 2011 at 10:25 AM


I was going through your error controller.

if (error is AwesomeDemoException)      

         return View("Expected", new ErrorDisplay { Message = error.Message });          

  return View("Error", new ErrorDisplay{Message = error.Message});


Why is two views being returned?

Also it seems all controller needs to be initialized due to "controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));"

Any way out of this?

Is handle error attribute not a good way to handle errors in mvc?  



Thanks and best regards


Jan 10, 2011 at 7:08 AM


one is for the expected error, and the other one for the unexpected

where did you saw "controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));" ?

HandleError, don't know, never used it

Jan 10, 2011 at 8:37 AM


// Call target Controller and pass the routeData.      

     IController errorController = new ErrorController();            errorController.Execute(new RequestContext(                 new HttpContextWrapper(Context), routeData));

But I was wrong u don't need to do anything special to get it working...