The problem with ASP.NET MVC is that URLs generated thanks to the routing mechanism are based on the controller and action names. These will typically be resulting in URLs like /Account/Login, etc.
But the routing mechanism is not case-sensitive and a request to account/login works just the same.
It's not a good practice for the SEO to allow URLs with any casing because it could technically be considered to be duplicate pages with the same content.
Usage is very simple, just set the property like in the following code:
1: public static void RegisterRoutes(RouteCollection routes)
2: {
3: ...
4: routes.LowercaseUrls = true;
5: ...
6: }
You can test the modification with a simple action link:
1: @Html.ActionLink("Home", "Index", "Home")
An you will see this result:
1: <a href="/home/index">Home</a>
You don't have to worry about the capital letters in your URLs but this is not a reason to forget some good SEO practices: you can see some tips here.
Did you notice that as soon as you add an Area to the project, the urls are propercase again? http://stackoverflow.com/questions/13271048/mvc-4-routecollection-lowercaseurls-breaks-when-using-area
ReplyDeleteHi Marcel,
ReplyDeleteI have not yet tested it with Areas... Thank you for the info!
While you wait for a fix, you can try this package: http://lowercaseroutesmvc.codeplex.com/
Also please have a look at this package: https://www.nuget.org/packages/LowercaseDashedRoute/
ReplyDeleteAnd read the one-line configuration here: https://github.com/AtaS/lowercase-dashed-route
Hi Ata,
ReplyDeleteGood idea! Thanks for the link!
Denis
My pleasure!
ReplyDeleteThanks Denis.
ReplyDelete