2011-08-17 134 views
3

我想在两个网站之间共享身份验证,因为我正在慢慢重写旧功能的功能并转换到新功能。我在这里找到了一个答案:Sharing Authentication between ASP.NET sites在身份验证上设置域Cookie打破MVC中的身份验证

问题是,当我设置域属性时,身份验证Cookie停止工作。用户仍然被认证成功,cookie似乎被创建并正确设置...但是当网站被加载时,用户被强制登录屏幕。

我使用的是标准的MVC生成的验证码,这很好,只要域没有设置工作:

public void SignIn(string userName, bool createPersistentCookie) 
     { 
      if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); 

      FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); 

     } 

如果我调试,并期待在FormsAuthentication物体看起来域和其他一切设置正确。

那么可能会导致这种情况,我该如何解决?

回答