I have 2 controllers in different folders. /Areas/Admin/Controllers/ and the other one is in /Controllers.
Here's the code I'm using
@Html.ActionLink("Back", "Directory", "DirectoryWebService", new { ReturnUrl = Model.ReturnUrl }, new { @class = "common-button" })
Using the code from Views/Directories/filename.cshtml works fine and generates the correct link "/DirectoryWebService/Directory?returnUrl=/Default/Traceability" DirectoryWebService is in /Controllers folder
However, using this code from /Areas/Admin/Views/Organizations/Index.cshtml generates the following link "/Admin/DirectoryWebService/Directory ReturnUrl=/DirectoryWebService/Directory?returnUrl=/Default/Traceability" Controller for Index.cshtml is in /Areas/Admin/Controllers/ folder
The question is how can I avoid /admin in the path for the second case? I haven't mentioned in my code. PS I know about the a tag solution. It works fine but I need actionLink here.
CodePudding user response:
You may remove the area
variable from route.
@Html.ActionLink("Back", "Directory", "DirectoryWebService", new {
area = "",
returnUrl = Model.ReturnUrl
}, new {
@class = "common-button"
});