Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. routes.MapRoute(
  2. name: "SpecificAction",
  3. url: "{controller}/{action}/{id}-{id2}",
  4. defaults: new { controller = "Main", action = "SpecificAction", id = UrlParameter.Optional, id2 = UrlParameter.Optional }
  5. );
  6.  
  7. routes.MapRoute(
  8. name: "DefaultNoParams",
  9. url: "{controller}/{action}/",
  10. defaults: new { controller = "Main", Action = "Index" },
  11. namespaces: new string[1] { "Project.Controllers" }
  12. );
  13.  
  14. [HttpGet]
  15. public ActionResult TheAction()
  16. {
  17.  
  18. }
  19.  
  20. [HttpPost]
  21. public ActionResult TheAction([ModelBinder(typeof(SpecificModelBinder))] SpecificModel model)
  22. {
  23.  
  24. }
  25.  
  26. <a href="@Url.Action("TheAction", "Main")">The Action</a>
  27.  
  28. routes.MapRoute(
  29. name: "DefaultNoParams",
  30. url: "{controller}/{action}/",
  31. defaults: new { controller = "Main", Action = "Index" },
  32. namespaces: new string[1] { "Project.Controllers" }
  33. );
  34.  
  35. routes.MapRoute(
  36. name: "SpecificAction",
  37. url: "{controller}/{action}/{id}-{id2}",
  38. defaults: new { controller = "Main", action = "SpecificAction", id = UrlParameter.Optional, id2 = UrlParameter.Optional }
  39. );
  40.  
  41. <a href="@Url.Action("TheAction", "Main")">The Action</a>
  42.  
  43. <a href="/Main/TheAction">The Action</a>
  44.  
  45. routes.MapRoute(
  46. name: "SpecificAction",
  47. url: "{controller}/{action}/{id}-{id2}",
  48. defaults: new { controller = "Main", action = "SpecificAction",
  49. id = UrlParameter.Optional, id2 = UrlParameter.Optional }
  50. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement