Skip to content

Instantly share code, notes, and snippets.

@FernandoVezzali
Last active December 26, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoVezzali/7133208 to your computer and use it in GitHub Desktop.
Save FernandoVezzali/7133208 to your computer and use it in GitHub Desktop.
Custom Route MVC
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "CustomRoute",
url: "{controller}/{action}/{startYear}/{startMonth}/{startDay}/{endYear}/{endMonth}/{endDay}",
defaults: new
{
controller = "Home",
action = "Index",
startYear = 2013,
startMonth = 6,
startDay = 1,
endYear = 2013,
endMonth = 6,
endDay = 30,
}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment