Unexpected end of file. The following items are not closed: Cookie, SecurityContextToken. Line 1, Position 2998

I have implemented ADFS authentication for an asp.net 4.0 application. I placed the application in a production environment with webfarm setup. The website is working fine and all images are displayed correctly in IE8 browser. But when I tried to view the application in the Safari browser, the website did not work several times, and the images also did not display correctly.

Using Fiddler, I found that sometimes images do not display properly and the following errors occur:

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)

Then I tried to execute the following link:

http://social.msdn.microsoft.com/Forums/en/Geneva/thread/ea00ec3f-ebdf-427c-929f-d4a196650552

. webfarm, , - IE8 Safari. IE8 , , Safari , webfarm .

, ADFS cookie, cookie . IE8 cookie Safari 4097 .

, cookie Safari.

- , .

,

+5
2

Now the problem is solved by including persistent cookies (Sticky Sessions) in the load balancer in the webfarm script.

+2
source

I dealt with this problem by reducing the number of claims returned by STS. This will reduce the size of the cookie. I brought out another tool to capture the data that I need using the service that I implemented.

+1
source

All Articles