2

我们有一个现有的 ASP.Net Web Forms 应用程序,它安装在每个客户自己的服务器上。这已经被他们所有人使用了一段时间并且从来没有真正遇到过问题,我们现在有些人在通过 iPad 登录时遇到错误:

invalid value for encrypted ticket parameter

我们这里有 iPad 进行测试,但我们没有收到错误,尽管让它们确保 cookie 在 Safari 设置中被接受,甚至要求他们在 iPad 上试用 Chrome 也没有什么区别。无法复制它使得诊断变得非常困难,所以我希望有人以前可能遇到过这个问题。

它使用带有自定义 MembershipProvider 的表单身份验证。

4

2 回答 2

0

您必须检查 HttpCookie 的 null 以及它的值,如下所示。

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

        }
    }
于 2014-07-19T06:09:11.530 回答
0

如果您将无效字符串传递给System.Web.Security.FormsAuthentication.Decrypt. 最常见的是它试图通过cookieName而不是cookieValue.

下面是获取ASPXAUTH cookie值+信息的方法:

string authCookieValue = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value;
var cookieInfo = System.Web.Security.FormsAuthentication.Decrypt(authCookieValue);
于 2014-03-10T22:41:16.947 回答