Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC HandleError
    primarykey
    data
    text
    <p>How do I go about the <code>[HandleError]</code> filter in asp.net MVC Preview 5?<br> I set the customErrors in my Web.config file</p> <pre><code>&lt;customErrors mode="On" defaultRedirect="Error.aspx"&gt; &lt;error statusCode="403" redirect="NoAccess.htm"/&gt; &lt;error statusCode="404" redirect="FileNotFound.htm"/&gt; &lt;/customErrors&gt; </code></pre> <p>and put [HandleError] above my Controller Class like this:</p> <pre><code>[HandleError] public class DSWebsiteController: Controller { [snip] public ActionResult CrashTest() { throw new Exception("Oh Noes!"); } } </code></pre> <p>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.</p> <p>This site was ported from preview 3 to 5. Everything runs (wasn't that much work to port) except the error handling. When I create a complete new project the error handling seems to work.</p> <p>Ideas?</p> <p><strong>--Note--</strong><br> Since this question has over 3K views now, I thought it would be beneficial to put in what I'm currently (ASP.NET MVC 1.0) using. In the <a href="http://www.codeplex.com/MVCContrib" rel="noreferrer">mvc contrib project</a> there is a brilliant attribute called "RescueAttribute" You should probably check it out too ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload