正在设置的 cookie 遇到一个奇怪的问题。大多数情况下,一切都按预期工作,但有时我会收到错误
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at System.IdentityModel.Services.ChunkedCookieHandler.ReadInternal(String name, HttpCookieCollection requestCookies)
at System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken)
at System.IdentityModel.Services.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)
我可以一遍又一遍地执行相同的步骤,此错误将随机显示。也许在 5 日去然后 10 日去下一次。
当我查看浏览器中的 cookie 时,我可以看到错误发生时结束标记的最后几个字符被重复。 Cookie如下(重要位),
FedAuth={base64string}
FedAuth1={base64string}cml0eUNvbnRleHRUb2tlbj4=
FedAuth2=b2tlbj4=
注意 FedAuth1 如何以 FedAuth2 的字符结束。由于某种原因,这个 FedAuth2 cookie 被不必要地创建并导致字符串以
结尾</SecurityContextToken>oken>
(base64 解密)。
我很迷茫...
最佳答案
我仍然不确定为什么会发生这种情况,但我设法通过重命名我的一些角色来解决问题,这样 cookie 就不会超过 2 个 FedAuth cookie。问题似乎出在创建的第三个 cookie 上。
关于c# - 联合身份 token 复制字符以关闭标签(cookie)(使用 Thinktecture Identity Server),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26837147/