区域特定的登录页面

| 在我的MVC 3 .net应用程序中,我有两个区域,一个区域称为Admin,另一个区域称为Student。我使用内置的成员资格系统进行用户身份验证,并且这两个区域之间是统一的。问题是,我要使用区域特定的登录页面,因为这两个区域在设计上有很大不同(学生针对移动设备)。据我所知,我只能在Web.config中为应用程序指定一个登录页面,如下所示:
<authentication mode=\"Forms\">
   <forms loginUrl=\"~/Admin/Account/LogOn\" timeout=\"2880\" />
</authentication>`
在这种情况下,如何为同一个会员系统实现几个登录页面?     
已邀请:
您只能为ASP.NET应用程序指定1个登录URL,因此您需要执行以下变通方法: 在每个Araa中,在应用程序的根目录中都有一个Login控制器以及一个主Login控制器。 在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中,配置表单身份验证以在根应用程序中使用Login控制器:
<forms loginUrl=\"~/LogOn\" timeout=\"2880\" />
然后在root登录控制器中,执行默认操作中的以下操作:
//
// 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.
}
    
您应该阅读此白皮书。在那里描述了您问题的解决方案。     

要回复问题请先登录注册