单个登录多个ASP MVC 3应用程序

kba*_*che 3 authentication single-sign-on asp.net-mvc-3

我有一个有两个应用程序的解决方案.是否可以让用户只登录一次?

例如,在主应用程序中,我执行如下身份验证:

FormsAuthentication.SetAuthCookie(ContactFound.ContaLogin, model.RememberMe);
Run Code Online (Sandbox Code Playgroud)

我把这段代码放在web.config文件中:

<authentication mode="Forms">
  <forms 
    loginUrl="~/Account/LogIn" 
    defaultUrl="~/Account/LogOn" 
    timeout="15"
  />      
</authentication>
Run Code Online (Sandbox Code Playgroud)

我应该添加什么,以便当用户登录时,在主应用程序中,当他连接到第二个应用程序时,我们不会要求他再次登录?

han*_*ngy 5

由于您要在同一地址托管两个应用程序,因此可以通过将<machineKey>(web.config)设置为两个应用程序的相同值来轻松实现.之后,登录到另一个应用程序后,您应该自动登录到一个应用程序.

进一步阅读: