本文介绍了encryptedTicket 参数的值无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近修改了我公司 eComm 站点的登录信息,使其具有保持登录状态"功能.主要更改是使这些用户的表单身份验证 cookie 持久化.

I recently modified the login for my companies eComm site to have a "Keep me logged in" feature. The primary change was to make the forms authentication cookie persistent for these users.

更改发布后,我开始在日志中看到此异常:

After the change was released I started seeing this exeception in my logs:

Invalid value for 'encryptedTicket' parameter
at System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)

问题似乎是特定于用户代理的.唯一记录错误的用户代理是:

The problem seems to be user agent specific. The only user agents the error has been recorded for are:

  • Mozilla/5.0(iPad;U;CPU OS 4_3_3,如 Mac OS X;en-us)AppleWebKit/533.17.9(KHTML,如 Gecko)版本/5.0.2 Mobile/8J2 Safari/6533.18.5

  • Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5

eTailInsights 标签标识符/1.0

eTailInsights Tag Identifier/1.0

我有一台配备上述配置的 iPad.第一次登录尝试有效.但是关闭浏览器并返回站点,从而使用持久性 cookie,会导致错误.

I have an iPad with the configuration listed above. The first login attempt works. But closing the browser and going back to the site, thus using the persistent cookie, causes the error.

该行为在不同环境中也不一致.它在我的本地机器和测试服务器上运行良好,但在生产中失败.这使得故障排除变得困难.

The behavior is also inconsistent across environments. It works fine against my local machine and test server, but fails on production. Which makes it difficult to troubleshoot.

其他版本的 iOS/Safari 可以正常登录.

Other versions of iOS/Safari can login fine.

搜索这个错误出现了几个 引用 对 Web 表单和较新浏览器版本的问题.不过,这似乎与我的场景不一致.我没有看到新浏览器的错误,我的网站是 MVC.

Searching for this error turned up several references to a problem with web forms and newer browser versions. This does not seem consistent with my scenario though. I'm not seeing errors for new browsers and my site is MVC.

我发现了一个与我类似的问题,但没有答案.

I found one question similar to mine, but with no answer.

有人知道这里发生了什么吗?

Anybody know what is happening here?

推荐答案

我遇到了同样的问题,这是因为我得到了 authCookieValue 的 null 或空值.所以我的建议是你必须检查 HttpCookie 的 null 以及它的值,如下所示.

I have faced same issue this is because I was getting null or empty value of authCookieValue . So my suggestion is that you have to check null for HttpCookie and also for it's value as given below .

HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
        if (authCookie != null)
        {
            //Extract the forms authentication cookie
            if (!string.IsNullOrEmpty(authCookie.Value))
            {
                FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                string email = authTicket.UserData;

                // and now process your code as per your condition

            }
        }

这肯定会帮助你.

这篇关于encryptedTicket 参数的值无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 15:58