How to link cshtml page using href in mvc4

I want to link the Menu.cshtml page using an anchor tag with href so that whenever I click on the menu link in the navigation bar I have to direct me to Menu.cshtml. I tried using this code several times, but I cannot do this. Here is the code I'm using:

<a class="page-scroll" href="~/Views/Home/Menu.cshtml">Menus</a>
+4
source share
4 answers

You can try to use the ActionLink html helper and let this method create the correct link.

@Html.ActionLink("Menus","Menu","Home", null, new { @class = "page-scroll" })
+6
source

ASP.NET MVC . MVC. ASP.NET MVC , . actionlink , . :

@Html.ActionLink("Menus", "Action", "Controller", null, new { @class = "page-scroll" });

, HomeController Menu. :

public ActionResult Menu()
{
    return View();
}

ASP.NET MVC Menu.cshtml Views/Home/. actionlink, , :

@Html.ActionLink("Menus", "Menu", "Home", null, new { @class = "page-scroll" });

href. @Html.ActionLink , href, ( MVC ):

<a class="page-scroll" href="/Home/Menu">Menus</a>
+3

Try this method used for redirection.

@Html.ActionLink("Menus", "Menu", "Home", new {@class="page-scroll"});
+2
source

Image as an anchor tag in Asp.net Mvc 5

When you want a logo as an action link

href="~/"

on the layout page to redirect to the home page

0
source

Source: https://habr.com/ru/post/1611066/


All Articles