Reputation: 103
I have this error in the navbar in asp.net mvc
And this id my code
<li class="nav-item nav-link" role="presentation">
<a class="nav-link" @Html.ActionLink("Customers", "Index", "Customers") />
</li>
So why this character come />
The close for the
Upvotes: 0
Views: 56
Reputation: 24957
You're using Html.ActionLink
inside anchor tag, which is totally wrong:
<a class="nav-link" @Html.ActionLink("Customers", "Index", "Customers") />
I suggest you to use ActionLink
helper alone with @class
attribute instead:
@Html.ActionLink("Customers", "Index", "Customers", null, new { @class = "nav-link" })
Or use @Url.Action
with anchor tag:
<a class="nav-link" href="@Url.Action("Index", "Customers")">Customers</a>
Upvotes: 1
Reputation: 784
You need to change the line:
<a class="nav-link" @Html.ActionLink("Customers", "Index", "Customers") />
to
<a class="nav-link" href="@Url.Action("Index", "Customers")">Customers</a>
or:
@Html.ActionLink("Customers", "Index", "Customers", null, new {@class = "nav-link"})
This is because @Html.ActionLink()
generates the entire anchor (<a>
) element whereas @Url.Action()
just generates the URL for the route, you need to do one or the other.
Upvotes: 0