Advertisement
Guest User

How do I set a “Default Action” for my Controller that will be called when no other action matches

a guest
Feb 28th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. routes.MapRoute("Default", "{controller}/{action}/{id}",
  2. new { controller = "Home", action = "Index", id = "" });
  3.  
  4. protected override void HandleUnknownAction(string actionName) {
  5. //your code here.
  6. }
  7.  
  8. routes.MapRoute("default-action", "{controller}/{actionName}/{id}", new {action="DefaultAction"});
  9.  
  10. public ActionResult DefaultAction(string actionName, string id) {
  11. //handle default action
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement