Without creating my own ActionLink HtmlHelper is there a way to force any ActionLinks to be rendered lowercase?
Update:
Check out the following links for extending the RouteCollection to add LowecaseRoutes
[http://www.makiwa.com/index.php/2008/05/31/lowercase-mvc-route-urls/]
[http://goneale.wordpress.com/2008/12/19/lowercase-route-urls-in-aspnet-mvc/]
Update - 02/03/2011: Since the two links above now nolonger work, i'd made a post a while back with my solution
http://blog.lukesmith.net/2009/02/01/generating-and-enforcing-that-any-link-and-request-is-lowercase-with-aspnet-mvc/
Using STYLE="text-transform:lowercase" 'Hullo, Mole!'
Solution : LowercaseUrls property on the RouteCollection class has introduced in ASP . NET 4.5. Using this property we can lowercase all of our URLs.
The best way to handle this, is at the routing level. Force all route paths to be lowercase, and it will properly propagate to your action links etc.
The way I've solved this, is to create a new route class that inherits Route
and simply overrides the GetVirtualPath
method;
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
var virtualPath = base.GetVirtualPath(requestContext, values);
if (virtualPath != null)
virtualPath.VirtualPath = virtualPath.VirtualPath.ToLowerInvariant();
return virtualPath;
}
I've also created a few extension methods for RouteCollection
to make it easy to use this new route class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With