MVC 4 razor actionlink address route adds pound char in between

170 Views Asked by At

the reason of this question is because I am having troubles with a route address in MVC 4 application, what is happening here is that I have an action link in this way in a view:

<li>@Html.ActionLink("Description", "Action", "Controller")</li>

And when I run the app in the HTML in the web browser appear the link generated correct

<li><a href="/controller">description</a></li>

but when I click on the link in the web address bar the destination route appears as follows:

http://localhost:port/#/Controller

Is inserting a "#" char in between, is doing this for all of the links in my different views, it do the same when I deploy the App in a web server too no only in my local and this makes that the destination page don't appear correct, I don't know the reason of this, I have been searching but without success, hope you can help me, thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

I found the reason for that behavior, it was because I have the script load for jquery mobile on the head section in the _Layout_cshtml file like this

 <head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width" />
    @Scripts.Render("~/bundles/jquery")
    @Styles.Render("~/Content/mobilecss", "~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquerymobile")
</head>

What I do was change the location of jquerymobile script to the end of the _Layout.cshtml

    @Scripts.Render("~/bundles/jquerymobile")
    @RenderSection("scripts", required: false)
</body>

With this change the web route was created correctly, I hope this helps to somebody.