ASP MVC href to a controller/view
There are a couple of ways that you can accomplish this. You can do the following:
<li>
@Html.ActionLink("Clients", "Index", "User", new { @class = "elements" }, null)
</li>
or this:
<li>
<a href="@Url.Action("Index", "Users")" class="elements">
<span>Clients</span>
</a>
</li>
Lately I do the following:
<a href="@Url.Action("Index", null, new { area = string.Empty, controller = "User" }, Request.Url.Scheme)">
<span>Clients</span>
</a>
The result would have http://localhost/10000
(or with whatever port you are using) to be appended to the URL structure like:
http://localhost:10000/Users
I hope this helps.
how about
<li>
<a href="@Url.Action("Index", "Users")" class="elements"><span>Clients</span></a>
</li>
Try the following:
<a asp-controller="Users" asp-action="Index"></a>
(Valid for ASP.NET 5 and MVC 6)
Here '~' refers to the root directory ,where Home is controller and Download_Excel_File is actionmethod
<a href="~/Home/Download_Excel_File" />
You can modify with the following
<li><a href="./Index" class="elements"><span>Clients</span></a></li>
The extra dot means you are in the same controller. If you want change the controller to a different controller then you can write this
<li><a href="../newController/Index" class="elements"><span>Clients</span></a></li>