C# ASP.NET 4.5身份验证cookie未在Azure Web角色上持久化

C# ASP.NET 4.5身份验证cookie未在Azure Web角色上持久化,c#,asp.net,forms,authentication,cookies,C#,Asp.net,Forms,Authentication,Cookies,我对Azure WebRole上的表单身份验证有问题。它不存储登录的身份验证cookie。一旦用户启动新会话,他就必须再次登录。 首先,我尝试: FormsAuthentication.SetAuthCookie(userIdent, rememberMe); 现在手动操作: var ticket = new FormsAuthenticationTicket(1, userIdent, DateTime.Now, DateTime.Now.AddMonths(6),rememberMe,st

我对Azure WebRole上的表单身份验证有问题。它不存储登录的身份验证cookie。一旦用户启动新会话,他就必须再次登录。 首先,我尝试:

FormsAuthentication.SetAuthCookie(userIdent, rememberMe);
现在手动操作:

var ticket = new FormsAuthenticationTicket(1, userIdent, DateTime.Now, DateTime.Now.AddMonths(6),rememberMe,string.Empty, FormsAuthentication.FormsCookiePath);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName,encryptedTicket)
{
    Path = FormsAuthentication.FormsCookiePath,
    HttpOnly = true
};
if (rememberMe)
{
    cookie.Expires = ticket.Expiration; 
}
Response.Cookies.Add(cookie);
下面是web.config中的一个片段:

<machineKey decryption="Auto" decryptionKey="<My Decryption Key>" validation="SHA1" validationKey="<MyValidationKey>" />

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" slidingExpiration="true" timeout="2880" cookieless="UseCookies" />
</authentication>

但问题依然存在。有时候它真的记得吗?。因为它在Azure WebRole中运行,所以我们将MachineKey添加到web.config

这个问题可能与Azure Web角色无关,因为我们注意到在本地运行时出现了相同的行为。本地主机:7778