Pea*_*rog 10 .net asp.net iis asp.net-mvc webforms
我最近修改了我的公司eComm网站的登录名,以便"保持登录状态"功能.主要变化是使表单身份验证cookie对这些用户持久.
更改发布后,我开始在日志中看到此异常:
Invalid value for 'encryptedTicket' parameter
at System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)
Run Code Online (Sandbox Code Playgroud)
问题似乎是用户代理特定的.记录错误的唯一用户代理是:
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
eTailInsights标签标识符/ 1.0
我的iPad配有上面列出的配置.第一次登录尝试有效.但是关闭浏览器并返回到站点,从而使用持久性cookie会导致错误.
跨环境的行为也不一致.它对我的本地机器和测试服务器工作正常,但生产失败.这使得排除故障变得困难.
其他版本的iOS/Safari可以正常登录.
搜索此错误会引发对Web表单和较新浏览器版本问题的多次引用.这似乎与我的场景不一致.我没有看到新浏览器的错误,我的网站是MVC.
我发现了一个类似于我的问题,但没有答案.
谁知道这里发生了什么?
Dil*_*165 10
我遇到了同样的问题,因为我得到了authCookieValue的null或空值.所以我的建议是你必须检查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
}
}
Run Code Online (Sandbox Code Playgroud)
这肯定会对你有所帮助.
如果您将无效字符串传递给 ,就会发生这种情况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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9854 次 |
| 最近记录: |