ASP MVC - Getting Controller Level error handling

Posted by RP on Stack Overflow See other posts from Stack Overflow or by RP
Published on 2010-03-09T19:51:37Z Indexed on 2010/05/09 21:18 UTC
Read the original article Hit count: 293

Filed under:
|

How to get Controller-Level error handling:

This is my map-route:

routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
);

And I have 2 controllers - HomeController and AwayController

I want both both controllers to handle their own errors

For example, a call to

/Home/InvalidAction would be handled by one method

and

/Away/InvalidAction would be handled by another method

Where InvalidAction currently results in a 404 as there's no Action method with that name

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about error-handling