I again have problem with routing 🙂
When I run application if user is not authenticated he is redirected to login page.
I use FormsAuthentication
Login page is in area Account
Current URL is
http://localhost:38962/Account/Home/Index?ReturnUrl=%2f
Setup from web config
<authentication mode="Forms">
<forms loginUrl="~/Account/Home/Index" timeout="2880" />
</authentication>
I have tried to set route in AccountAreaRegistration class
context.MapRoute("home_login",
"",
new { area = "Account", controller = "Home", action = "Index", ReturnUrl = UrlParameter.Optional });
and a few others setup bu can’t get login page and to URL stays just
http://localhost:38962
And I also have route in AccountAreaRegister
context.MapRoute(
"Account_default",
"Account/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Update 1
routes.MapRoute(
"Default",
"{controller}/{action}/{cityId}",
new { area = "MainArea", controller = "Home", action = "Index", cityId = UrlParameter.Optional },
new string[] { "MCN.WebUI.Areas.MainArea.Controllers" }).DataTokens.Add("area", "MainArea");
Fix your MapRoute function call, second parameter should be
remove the area in the third parameter
web.config