我有一个基于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();
}
具有相同 web.config 的相同代码部署到两个 Web 服务器。然而,其中一个工作正常,而另一个总是有它的ticket
等于空。如果我删除if (ticket != null)
然后抛出空引用异常。除了门票部分外,它们的输出完全相同。
Web 服务器在 Windows Server 2008 R2 SP1 上运行,并安装了 .NET Framework 4。我确信两个网络服务器上的代码完全相同,包括 machineKey:
<machineKey validationKey="xxx" decryptionKey="yyy" validation="SHA1" decryption="AES" />
怎么会发生这种事呢?对于这个奇怪的问题你有什么想法吗?
UPDATE
MS BUG,需要更新包:http://support.microsoft.com/kb/2656351 http://support.microsoft.com/kb/2656351
在使用负载均衡器时,我遇到了您提到的这个问题。 [.net框架4.0]
所有的事情都被验证了很多次,但没有成功。
只是想分享以下链接作为最后的安全更新:MS11-100 http://support.microsoft.com/kb/2656351已经解决了我的问题。
Tony 认为这可能是 .net 4.0 中的错误http://tmoaikel.wordpress.com/2012/03/21/formsauthentication-decrypt-returns-null/ http://tmoaikel.wordpress.com/2012/03/21/formsauthentication-decrypt-returns-null/,已通过上述补丁修复。
也许这可以帮助你取得进一步的进步。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)