FormsAuthentication.Decrypt始终在其中一个Web服务器中返回null

我有一个基于asp.net 4.0的webform应用程序,部署到两个不同的服务器。 webform应用程序只有一个Default.aspx及其代码:

protected void Page_Load(object sender, EventArgs e) { MachineKeySection section = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey"); this.Response.Write(section.DecryptionKey); this.Response.Write("
"); this.Response.Write(section.ValidationKey); this.Response.Write("
"); var authToken = "xxxxxx"; //the real token is obviously not xxx, just an example here this.Response.Write(authToken); this.Response.Write("
"); var ticket = FormsAuthentication.Decrypt(authToken); if (ticket != null) this.Response.Write(ticket.Name); this.Response.End(); }

将具有相同web.config的相同代码部署到两个Web服务器。 但是,其中一个工作正常,另一个总是将其ticket等于null。 如果我删除if (ticket != null)则抛出空引用exception。 它们具有完全相同的输出,除了票证部分。

Web服务器在Windows Server 2008 R2 SP1上运行,并安装了.NET Framework 4。 我确定两台Web服务器上的代码完全相同,包括machineKey:

  

怎么会发生这种情况? 你对这个问题有什么看法吗?

UPDATE

MS BUG,需要更新软件包: http : //support.microsoft.com/kb/2656351

在使用负载均衡器时,我遇到了你提到的这个问题。 [.net Framework 4.0]

所有事情都经过多次validation,没有成功。

只是想分享以下链接作为最后的安全更新: MS11-100修复了我的问题。

Tony认为这可能是.net 4.0 http://tmoaikel.wordpress.com/2012/03/21/formsauthentication-decrypt-returns-null/中的错误,这是由上述补丁修复的。

可能这可能会帮助你进一步发展。