我们的网站上有一个自定义 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/