MVC ActionLink how to specify text, name of action, controller and htmlattributes

I am trying to make an actionlink like:

<li>@Html.ActionLink("Home", "Index", "Invoice", new { id = "homelink" })</li> 

So, I have linkText, action name, controller name and link identifier.

However, there is no signature. The closest one has a route between the controller name and html attributes. I do not have any route values ​​that I need to add there.

Can someone please tell me how best to get around this?

+4
source share
2 answers

Set the route values ​​to null and your product will be useful!

 @Html.ActionLink("Home", "Index", "Invoice", null, new { id = "homelink" }) 
+5
source

Description

Assuming I understand what you are asking for, there is overload for this

Example

 @Html.ActionLink("LinkText", "ActionName", "ControllerName", null, new { id="homelink" }) 

Additional Information

+3
source

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


All Articles