Want more features on Pastebin? Sign Up, it's FREE!
Guest

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

By: a guest on Feb 28th, 2012  |  syntax: None  |  size: 0.41 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data