2011-09-27 84 views
3

我们在我们的网站上有一个定制的STS,它们都在Windows Azure中运行。 STS是ASP.NET 4.0,网站是MVC3。在过去的几天里,我开始看到了不少但以下情况除外显示了在我们的诊断日志:Windows Identity Foundation System.Xml.XmlException:文件意外结束

 
System.Xml.XmlException: Unexpected end of file. 
    at System.Xml.EncodingStreamWrapper.ProcessBuffer(Byte[] buffer, Int32 offset, Int32 count, Encoding encoding) 
    at System.Xml.XmlUTF8TextReader.SetInput(Byte[] buffer, Int32 offset, Int32 count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) 
    at System.Xml.XmlDictionaryReader.CreateTextReader(Byte[] buffer, Int32 offset, Int32 count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) 
    at System.Xml.XmlDictionaryReader.CreateTextReader(Byte[] buffer, Int32 offset, Int32 count, XmlDictionaryReaderQuotas quotas) 
    at Microsoft.IdentityModel.Web.SessionAuthenticationModule.GetKeyId(Byte[] sessionCookie) 
    at Microsoft.IdentityModel.Web.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) 
    at Microsoft.IdentityModel.Web.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) 
    at Microsoft.IdentityModel.Web.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) 
    at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously 

我不知道是否有什么问题,这可能最终用户或任何影响正在造成。如果有人能够阐明这种例外情况,以及我将来可以做些什么来防止这种例外情况,我会喜欢它。

回答

7

当您使用Wif时,Wif会将用户信息转换为美联储cookie,以便用户不需要一次又一次地进行身份验证。这个美联储cookie,会话cookie,是由会话认证模块为HttpContext和Thread设置用户的每个请求解释的。

由于用户信息可能很大,通常这个cookie被分成更小的块。

在您的情况下,发生的事情是SAM无法读取cookie中表示的数据。

您所看到的错误可能是浏览器限制提交的cookie数量/大小的最终结果。

对用户的影响是身份验证失败或500次,具体取决于如何处理此错误,我尚未调查。

我建议尝试查看您的网站实施了多少个Cookie。我曾经在一些帖子看到,Opera和Safari可能有麻烦与这些:

http://social.msdn.microsoft.com/Forums/eu/Geneva/thread/dc1e178f-46ab-4567-88b8-1f2541744908

+0

这正是它竟然是。在某些页面上,我们有谷歌分析,反伪造令牌等,这会导致域cookie的大小超过某些浏览器(safari,opera等)强加的4096字节限制。实施安全令牌缓存解决了问题。 – Jeff