How to use ActionLink with RouteValueDictionary?

I am trying to make my url like this:

http://domain.com/controller/action/123/SomeTextForSEO

I tried using Action Link, but instead of adding ?company=SomeTextForSEOinstead of the company name.

 <%: Html.ActionLink("DomainList", "Index", "DomainList", new { id = item.CompanyID, company = item.CompanyDisplayName.Trim() }, new object { })%> 

and now I think what I need to use RouteValueDictionary, but I'm not sure how to do this in ASP.NET syntax. Can someone point me in the right direction? Examples of MSDN are insufficient.

+3
source share
2 answers

If you go to global.asax.cs and add a new route, similar to the existing default route with the template

"{controller}/{action}/{id}/{company}"

Prior to the default installation, you should find that the link will be correctly generated with your ActionLink call as is.

, ( , ), HTC ;)

+3
+1

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


All Articles