c# - Windows 身份基础系统.Xml.XmlException : Unexpected end of file

标签 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

我不知道这对最终用户是否有任何影响,或者这可能会导致什么问题。如果有人能阐明这个异常以及我将来可以做些什么来防止它发生,我会很高兴。

最佳答案

当您使用 Wif 时,Wif 会将用户信息转换为 Fed cookie,这样用户就不需要一次又一次地进行身份验证。这个 Fed cookie, session cookie,是针对 session 身份验证模块解释的每个请求, session 身份验证模块为 HttpContext 和线程设置用户。

由于用户信息可能很多,通常此 cookie 会分成较小的部分。

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

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

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

我建议尝试查看您的网站分发了多少 cookie。我在一些帖子中看到 Opera 和 Safari 可能会遇到这些问题:

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

关于c# - Windows 身份基础系统.Xml.XmlException : Unexpected end of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7575188/

相关文章:

c# - 异常(exception)是 : InvalidOperationException - The current type, 是一个接口(interface),无法构造。您是否缺少类型映射?

asp.net - asp 的边框 :panel

asp.net - 通过 devenv.exe 构建站点有效,msbuild 失败

c# - 构建操作后 asp.net mvc 更新网站?

c# - Web API 安全和身份验证 - 不记名 token

javascript - 在单击函数上将模型值传递给 @Html.CheckBoxFor

asp.net-mvc - 解决 Asp.net mvc 上的 CS0246 错误

c# - 如何在 Silverlight 中为 HyperlinkBut​​ton 添加下划线?

c# - 包含正斜杠 (/) 的属性的 XPath 查询

c# - 如何使用 Windows 对话框复制(或删除等)多个文件(或目录)?