0
我再次遇到路由问题:) 当我运行应用程序,如果用户未通过身份验证,他将被重定向到登录页面。 我用FormsAuthentication
登录页面是在区域帐户 当前的URL是从web配置身份验证 - 路由上的asp mvc区域问题
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 });
和其他一些设置BU不能获取登录页面和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");
它仍然是相同的区域。我不知道这是否重要。在global.asax中,我有默认路由,将用户导向另一个区域的页面。该页面需要认证(控制器具有Authorize属性)。如果用户未通过身份验证,则说明此登录页面是以此整个网址开始的。 – 1110 2012-01-29 14:54:27
你可以发布该代码吗?你是否也启用了web.config中的授权? – chandmk 2012-01-29 15:03:07
我已更新问题 – 1110 2012-01-29 15:08:19