Adding Area atribute to the Html.ActionLink Does NOT Work

30 Views Asked by At

First of all I would like to make a comment about .NET Core.. Having working with .NET Framework... .NET Core is a JOKE! I cannot believe that Microsoft has put out a platform that seems to be difficult to work with. Every step is a struggle to get something done that is effortless to do in .NET Framework. Now I am stuck on generating a simple anchor tag using the Html.ActionLink (and other methods).. It seems that the Area attribute of the helper does not work. I can browser to the page I want to link to but ASP.NET using Razor cannot build the link for me. So now i am stuck with a huge project because I cannot add the area to the url. This is simply unproductive and a waste of time learning Core. Unfortunately I am too far into the project to go back to .NET Framework. Any suggestions would be greatly appreciated. I am a successful 30 year programmer and have learned many technologies on my own and I have never experienced anything like this before! I was advised by seasoned programmers to stay away from Core... Now I know what they were talking about.

This is my code to create the link:

@Html.ActionLink("View", "Customer", "Accounts", new { CustomerID = Model.Customers[iRow].CustomerGUID }, new { @area = "Admin", @style = "", @class = "copy-01a" })
1

There are 1 best solutions below

0
Qing Guo On

Please try to add @area into routeValues :

@Html.ActionLink("View", "Customer", "Accounts", new { CustomerID = Model.Customers[iRow].CustomerGUID, @area = "Admin" }, new {  @style = "", @class = "copy-01a" })

or

@Html.ActionLink("View", "Customer", "Accounts", new { CustomerID = Model.Customers[iRow].CustomerGUID, area = "Admin" }, new {  @style = "", @class = "copy-01a" })

I do a demo it works fine.

enter image description here

You can read Areas in ASP.NET Core to know more.