我有一个基于asp.net 4.0的webform应用程序,部署在两个不同的服务器上。webform应用程序只有一个默认值。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();
}
相同的代码与相同的web。Config被部署到两个web服务器上。然而,其中一个工作得很好,而另一个总是让它的ticket
等于零。如果我删除if (ticket != null)
,则抛出空引用异常。它们的输出完全相同,除了票证部分。
web服务器运行在Windows Server 2008 R2 SP1上,安装了。net framework 4。我确信两个web服务器上的代码是完全相同的,包括machineKey:
<machineKey validationKey="xxx" decryptionKey="yyy" validation="SHA1" decryption="AES" />
怎么会这样?你对这个奇怪的问题有什么想法吗?
MS BUG,需要更新包:http://support.microsoft.com/kb/2656351
在使用负载均衡器时,我遇到了您提到的这个问题。[.net Framework 4.0]
所有的事情都被验证了这么多次,没有成功。
只是想分享下面的链接,因为最终安全更新:MS11-100已经解决了我的问题。
Tony认为这可能是。net 4.0 http://tmoaikel.wordpress.com/2012/03/21/formsauthentication-decrypt-returns-null/中的一个bug,上面的补丁已经修复了。