I have two areas home and account.
When I'm on the Index.cshtml page of the home controller and I want to go to my account controller's Login.cshtml page I use this actionlink to go to the login action method which should view Login.cshtml
@Html.ActionLink("Log in", "Login", "Account", routeValues: new { area = "Account", returnUrl = Request.RawUrl }, htmlAttributes: new { id = "loginLink" })
and in the browser I see
https://localhost:44301/Account/Login?returnUrl=%2Fhome%2Findex
but I get a HTTP 404 error, not found.
Here is my AccountAreaRegistration.cs page RegistrationArea method
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Account_default",
"{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
Here is my routeconfig.cs
var route = routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional }
);
route.DataTokens["area"] = "Home";
FYI - If I change the lines in HomeAreaRegistration and AccountAreaREgistration to
"Home/{controller}/{action}/{id}", "Account/{controller}/{action}/{id}",
I can successfully route to and connect to login.cshtml, but I'm then connecting to
localhost/Home/Home/Index localhost/Account/Account/Login
but I want to connect with only one Home and one Account