6

asp.net 4.0 アプリケーションに ADFS 認証を実装しました。webfarm 構成を使用して、実稼働環境でアプリケーションをホストしました。Web サイトは正常に機能し、すべての画像が IE8 ブラウザーで適切にレンダリングされます。しかし、Safari ブラウザーでアプリケーションを参照しようとすると、Web サイトが機能しないことがあり、画像も適切にレンダリングされません。

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 構成で 1 つのサーバーを停止しようとしたところ、IE8 および Safari ブラウザーで Web サイトが正常に機能していることがわかりました。IE8 ブラウザーでは常に機能し、すべての画像が適切にレンダリングされますが、Web ファーム内の両方のサーバーがオンになっている場合、Safari ブラウザーはそうではありません。

分析の結果、ADFS から Cookie の形式でいくつかのクレーム情報を取得しており、Cookie の長さがそれ以上であることがわかりました。IE8 ブラウザーの場合、Cookie の長さはより長く、Safari の場合、許容される制限は 4097 文字です。

そこで、Safari ブラウザーの Cookie の制限を最大化することを考えました。

コードサンプルを提供して、この問題を解決するのを手伝ってください。

よろしくお願いいたします。 サントッシュ・クマール・パトロ

4

2 に答える 2

3

この問題は、webfarm シナリオのロード バランサーで永続的な Cookie (Sticky Sessions) を有効にすることで解決されるようになりました。

于 2012-02-03T07:20:01.593 に答える
2

STS から返されるクレームの数を減らすことで、この問題に対処しました。これにより、Cookie のサイズが小さくなります。実装したサービスを介して必要なデータを取得する別の手段を推測しました。

于 2013-03-27T20:05:10.887 に答える