Вопрос

I have this ActionLink to login:

@Html.ActionLink("Login", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })

From the Home view, it works, resulting in this url:

http://localhost:12676/Account/Login

But then, when another area is accessed, the ActionLink results in this url:

http://localhost:12676/Admin/ManagerAccounts/Login/loginLink

What do I need to change to cause the ActionLink to always result in ~/Account/Login?

Это было полезно?

Решение

To force the ActionLink to be relative to the root of the site, and not the current Area, give it an empty string Area as a route value, otherwise it will try to use the current area in the route:

@Html.ActionLink("Login", "Login", "Account", routeValues: new { Area = "" }, htmlAttributes: new { id = "loginLink" })
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top