Reputation: 127
I'm on working an Asp.net MVC project that I have use an URL like that:
<a href="@Url.Action("Index","Privacy")#Legal" target="_blank">Terms and Conditions</a>
Which I want it go to: /Privacy/Index#Legal
But it auto added the slash which make the URL not good: /Privacy/Index#/Legal
What I'm wrong? Sorry I'm a new Asp.net MVC developer. Thanks
UPDATED: I found the problem that my project used AngularJS, the solution that config the $locationPrivider will solve the problem:
$locationProvider.html5Mode({
enabled: true,
requireBase: false,
rewriteLinks: false
});
Thanks for all your support.
Upvotes: 1
Views: 1511
Reputation: 8781
You can configure whether or not to use trailing slash in urls throug AppendTrailingSlash
property of RouteCollection
object.
In order to remove it from all URLs in your application you should modify RegisterRoutes
method
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
///add this line
routes.AppendTrailingSlash = false;
}
}
Once you set this up @Url.Action("Index","Privacy")
will be generated without trailing slash
Upvotes: 3