I use the following in MVC to create a link to my home page in my application:
<a href="~/">home</a>
Unfortunately, when this is run under an app, this will create a link like
<a href="/app-name/">home</a>
Is there a way to create this link to the app-name without the trailing slash (or without just hardcoding the it)?
Our site is canonicalised so that any urls with a trailing slash end up being redirected to their non trailing slash version and because this link has a trailing slash on, it is causing unnecessary redirect hops, which is penalising our seo ratings
Thanks to the comment from Lajos Arpad, it got me of thinking into another of making up the url so I thought if I use the VirtualPathUtility.ToAbsolute I may be able to then substring the result.
But using the following meant I didn't need to substring to get the url I needed:
<a href="@VirtualPathUtility.ToAbsolute("~")">Home</a>
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