Why are these links in .NET MVC / Ratchet application not working?

248 Views Asked by At

When I click on links they do not seem to work. When I right click them and open in a new tab they open correctly.

I can't figure out the reason for this behavior.

Here is the code for my _layout.cshtml file

<!DOCTYPE html>
<html>
<head>
    ...
    <!-- Roboto -->
    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:400,500,700">

    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/ratchet")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/ratchet")

</head>
<body>

    <div class="content">
        @RenderBody()
    </div>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

And here is an example of a link I'd put in index.cshtml

  <a href="@Url.Action("NewList", "Home", null)">Submit</a>
  <a href="/Home/NewList">Submit 2</a>

Both static and generated behave the same leading me to think this is a Ratchet issue.

EDIT 1 Apparently even the toggle is not working (again no JS errors)

<div class="toggle active">
  <div class="toggle-handle"></div>
</div>
<div class="toggle">
  <div class="toggle-handle"></div>
</div>

It works in a plain HTML template so I must assume this is from a .Render issue?

http://goratchet.com/components/

EDIT 2:
Many of the components don't seem to be working, I've found a way to bypass this issue by replacing the links with forms that have a submit button and hidden values to POST to the required Action. Terrible for the UI but at least the buttons are working.

3

There are 3 best solutions below

1
On

Do you have both regular and .min versions of ratchet so it can be loaded via your /bundles/ratchet bundle? Make sure you have both, or if you only have the debug versions that you are running in debug mode (or if you have only the .min versions that you are running not in debug mode)

0
On

I would suggest you to move the links from body to head.

 @Scripts.Render("~/bundles/jquery")

 @Scripts.Render("~/bundles/bootstrap")

Move them to head section once.

3
On

Sometimes “HTTP Error 404.0 - Not Found” error is encountered when calling the view. One of the possible cause for this error just a dot (.) in the href. In case this problem is caused from the same issue try as below (attention to dot):

<a href="@Url.Action("NewList", "Home")">Submit</a>
<a href="./Home/NewList">Submit 2</a>

Update:

When creating a link to a controller action in ASP.NET MVC, using the generic ActionLink method is preferable, because it allows for strongly typed links that are refactoring friendly:

@Html.ActionLink("NewList", "Home") 

Hope this helps...