【发布时间】:2012-02-21 15:53:29
【问题描述】:
我又遇到了路由问题 :)
如果用户未通过身份验证,当我运行应用程序时,他将被重定向到登录页面。
我用FormsAuthentication
登录页面在区域帐户
当前网址是
http://localhost:38962/Account/Home/Index?ReturnUrl=%2f
从网络配置设置
<authentication mode="Forms">
<forms loginUrl="~/Account/Home/Index" timeout="2880" />
</authentication>
我尝试在 AccountAreaRegistration 类中设置路由
context.MapRoute("home_login",
"",
new { area = "Account", controller = "Home", action = "Index", ReturnUrl = UrlParameter.Optional });
和其他一些设置无法获取登录页面并且 URL 保持不变
http://localhost:38962
我在 AccountAreaRegister 中也有路线
context.MapRoute(
"Account_default",
"Account/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
更新 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");
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 routing asp.net-mvc-routing asp.net-mvc-areas