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

Che*_*hen 9 c# asp.net asp.net-mvc webforms

我有一个基于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("<br />");

    this.Response.Write(section.ValidationKey);
    this.Response.Write("<br />");

    var authToken = "xxxxxx";  
        //the real token is obviously not xxx, just an example here

    this.Response.Write(authToken);
    this.Response.Write("<br />");

    var ticket = FormsAuthentication.Decrypt(authToken);
    if (ticket != null) this.Response.Write(ticket.Name);
    this.Response.End();
}
Run Code Online (Sandbox Code Playgroud)

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

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

<machineKey validationKey="xxx" decryptionKey="yyy" validation="SHA1" decryption="AES" />
Run Code Online (Sandbox Code Playgroud)

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

UPDATE

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

R.C*_*R.C 1

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

所有的事情都被验证了很多次,但没有成功。

只是想分享以下链接,因为最终安全更新:MS11-100解决了我的问题。

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

也许这可以帮助你取得进一步的进步。