Windows Identity Foundation System.Xml.XmlException:意外的文件结尾

Jef*_*eff 3 c# asp.net asp.net-mvc wif

我们的网站上都有一个自定义STS,它们都运行在Windows Azure中.STS是ASP.NET 4.0,站点是MVC3.在过去的几天里,我开始看到我们的诊断日志中出现了以下异常中的一小部分:

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

我不知道最终用户是否有任何影响,或者可能导致什么问题.如果有人可以对这个例外情况有所了解,以及我将来可能做些什么来防止这种情况,我会很高兴.

Ata*_*can 7

当您使用Wif时,Wif会将用户信息转换为Fed cookie,以便用户无需一次又一次地进行身份验证.这个Fed 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