lowercase-dashed/hyphenated-routing-for-asp-net-mvc/like-this
See ata's blog post & discussion
Requires .NET 4.0 or .NET 4.5.
New: Support for 'namespace' constraints are added.New: Added support for Areas.
New: Many new overloads for the class constructor.
If you use: Html.ActionLink("User Profile", "UserProfile", "Account")
Without Lowercase Dashed Route the url is:
yoursite.com/Account/UserProfile
With Lowercase Dashed Route the url is:
yoursite.com/account/user-profile
routes.Add(new LowercaseDashedRoute("{controller}/{action}/{id}",
new RouteValueDictionary(
new { controller = "Home", action = "Index", id = UrlParameter.Optional }),
new DashedRouteHandler()
)
);
If you are using areas, use the code below in your XxxAreaRegistration.cs file instead of default one and replace "AreaName"s with yours:
var route = new LowercaseDashedRoute("AreaName/{controller}/{action}/{id}",
new RouteValueDictionary(
new
{
action = "Index",
id = UrlParameter.Optional
}),
new DashedRouteHandler(),
this,
context
);
context.Routes.Add("AreaName_default", route);
Developers:
Ata Sasmaz
Salar Khalilzadeh