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

mvc3 Routes setup as id, id2 id3

By: a guest on Mar 30th, 2012  |  syntax: None  |  size: 0.76 KB  |  views: 11  |  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. context.MapRoute(
  2.     "Admin_default3",
  3.     "Admin/{controller}/{action}/{id}/{id2}/{id3}",
  4.     new { action = "Index" }
  5. );
  6. context.MapRoute(
  7.     "Admin_default2",
  8.     "Admin/{controller}/{action}/{id}/{id2}",
  9.     new { action = "Index"}
  10. );
  11.  
  12. context.MapRoute(
  13.     "Admin_default",
  14.     "Admin/{controller}/{action}/{id}",
  15.     new { action = "Index", id = UrlParameter.Optional }
  16. );
  17.        
  18. public ActionResult Search(Guid? id, int? id2, bool? id3)
  19. {
  20.     Guid? source = id;
  21.     int daysOld = id2;
  22.     bool includeNonEnglish = id3;
  23.  
  24.     //.... Action!
  25. }
  26.        
  27. Html.ActionLink(title, "Action", "Controller", new { source = <value>, daysOld = <value>, includeNonEnglish = <value> });
  28.        
  29. Html.ActionLink(title, "Action", "Controller", new { id = <value>, id2 = <value>, id3 = <value> });
clone this paste RAW Paste Data