forum

Home / DeveloperSection / Forums / How to HandlError in mvc?

How to HandlError in mvc?

Anonymous User185829-Oct-2014
How do I go about the [HandleError] filter in asp.net MVC Preview 5?
I set the customErrors in my Web.config file

<customErrorsmode="On"defaultRedirect="Error.aspx">
  <errorstatusCode="403"redirect="NoAccess.htm"/>
  <errorstatusCode="404"redirect="FileNotFound.htm"/>
</customErrors>

and put [HandleError] above my Controller Class like this:

[HandleError]
    public class DSWebsiteController : Controller { [snip] public ActionResult CrashTest() { throw new Exception("Oh Noes!"); } }

Then I let my controllers inherit from this class and call CrashTest() on them. Visual studio halts at the error and after pressing f5 to continue, I get rerouted to Error.aspx?aspxerrorpath=/sxi.mvc/CrashTest (where sxi is the name of the used controller. Off course the path cannot be found and I get "Server Error in '/' Application." 404.


Updated on 29-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By