只能有一个ASP.NET应用程序指定1个登录网址,所以你需要做以下解决方法:
在每个ARAA有一个登录控制器,以及在主登录控制器应用程序的根。
在web.config中,请确保您有:
<configuration>
<location path="/Admin/Account/LogOn">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="/Student/Account/LogOn">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
在你的web.config配置窗体身份验证的根应用程序中使用的登录控制:
<forms loginUrl="~/LogOn" timeout="2880" />
然后在根登录控制器在默认操作中执行以下操作:
//
// GET: /LogOn
public ActionResult Index(string returnUrl)
{
var area = returnUrl.TrimStart('/').Split('/').FirstOrDefault();
if (!string.IsNullOrEmpty(area))
return RedirectToAction("LogOn", "Account", new { area });
// TODO: Handle what happens if no area was accessed.
}