Search code examples
htmlasp.net-mvchyperlink

Anchor link only works by "Open link in new tab" command


I meet this interesting situation:

<ul>
    @foreach (var item in Model)
    {
      <li>
        <a href="@Url.Action("Details", "Product", new { id = item.Id })" >@item.Name</a>
      </li>
    }
</ul>

When I click a link, nothing happen, product Details page does not open. But I do "Open link in new tab", then it opens. What can be it's reason?


Solution

  • You have some javascript code which is preventing the default action of the anchor tag to be executed. You could inspect the Network tab in FireBug or Chrome DevTools to see if some AJAX request is being made when you click on the link. You could try excluding javascript files until you find the one that is doing this.