if (rol == 1) { @Html.ActionLink("Личный кабинет", "MainPanel", "Admin", new {@class="polosaSleva"}) } 

There are 2 Teacher and Admin controllers. In one of the methods of the first controller, I create a link to the representation of the second. (Code on top). As a result, a link is created to the Teacher controller's MainPanel view and not the Admin. I can not understand what the problem is.

    1 answer 1

    In your case, the name of the controller was taken as a route object: enter image description here

     @Html.ActionLink( linkText : "Личный кабинет", actionName : "MainPanel", controllerName : "Admin", routeValues : null, htmlAttributes : new { @class = "polosaSleva" } ) 
    • Everything is working. Thank! What's the mistake? I always did ActionLink without routeValues ​​and everything worked fine. - Vivus
    • @Vivus you apparently did ActionLink on the action inside the controller, and overloading this method for the action in another controller requires the routeValues ​​parameter to be the fourth in a row. @ Html.ActionLink ("My Account", "MainPanel", "Admin", null, new {@ class = "polosaSleva"}) - Sergey Tambovtsev