微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我们的网站上都有一个自定义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,Encoding encoding,XmlDictionaryReaderQuotas quotas,OnXmlDictionaryReaderClose onClose)
   at System.Xml.XmlDictionaryReader.CreateTextReader(Byte[] buffer,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

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

解决方法

当您使用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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐