我已经为asp.net 4.0应用程序实现了ADFS身份验证。我已经使用webfarm配置在生产环境中托管了应用程序。该网站运行良好,所有图像都在IE8浏览器中正确呈现。但是,当我尝试在Safari浏览器中浏览应用程序时,网站无法正常工作,图像也无法正常呈现。
通过使用Fiddler我发现有时候图像渲染不正确并且出现以下错误:
Exception information:
Exception type: XmlException
Exception message: Unexpected end of file. Following elements are not closed: Cookie, SecurityContextToken. Line 1, position 2998.
Thread information:
Thread ID: 12
Thread account name: CT\acmeweb
Is impersonating: False
Stack trace: at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowUnexpectedEndOfFile(XmlDictionaryReader reader)
at System.Xml.XmlBaseReader.MoveToEndOfFile()
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlDictionaryReader.ReadContentAsChars(Char[] chars, Int32 offset, Int32 count)
at System.Xml.XmlBaseReader.ReadBytes(Encoding encoding, Int32 byteBlock, Int32 charBlock, Byte[] buffer, Int32 offset, Int32 byteCount, Boolean readContent)
at System.Xml.XmlBaseReader.ReadContentAsBase64(Byte[] buffer, Int32 offset, Int32 count)
at System.Xml.XmlDictionaryReader.ReadContentAsBytes(Boolean base64, Int32 maxByteArrayContentLength)
at System.Xml.XmlDictionaryReader.ReadContentAsBase64(Int32 maxByteArrayContentLength, Int32 maxInitialCount)
at System.Xml.XmlBaseReader.ReadContentAsBase64()
at System.Xml.XmlDictionaryReader.ReadElementContentAsBase64()
at Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver)
at Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver)
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)
然后我尝试按照下面提到的链接:
http://social.msdn.microsoft.com/Forums/en/Geneva/thread/ea00ec3f-ebdf-427c-929f-d4a196650552
但它对我也没有用。然后我尝试在webfarm配置中停止一台服务器,然后发现该网站在IE8和Safari浏览器中工作正常。在IE8浏览器中,它可以一直工作,并且所有图像都可以正常呈现,但是当webfarm中的两个服务器都打开时,Safari浏览器不会出现。
在分析中我发现从ADFS我得到一些cookie形式的索赔信息,cookie长度更多。对于IE8浏览器,cookie长度更长,对于Safari,允许的限制为4097个字符。
因此我想到了最大化Safari浏览器的cookie限制。
任何人都可以通过提供任何代码示例来帮助我解决此问题。
谢谢&问候, Santosh Kumar Patro
答案 0 :(得分:3)
现在通过在webfarm场景中的负载均衡器上启用持久性cookie(Sticky Sessions)来解决问题。
答案 1 :(得分:2)
我通过减少从STS返回的声明数量来处理此问题。这将减少cookie的大小。我推断了另一种通过我实现的服务获取所需数据的方法。