解决后会有100分的额外奖励!!formsauthentication.setauthcookie(username,false)的cookie.value问题 感谢回复程序和账号确实相同。就只有环境不一样。win2003 iis6和win2008 iis7加密后的结果和username长短无关。无论多长在2003中也是160位,2008也是232位username是当前登录的账号。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/songrun/archive/2013/06/08/3125668.html注意事项,参考 是否与.net framework 的版本有关,换一个高版本的试试、 如果你希望保持一致,需要自己写一个MembershipProvider,自己重载SetAuthCookie。那么你想怎么做就你决定了。google custom MembershipProvider 忘记说了 我们这个项目用的是forms表单类型。不是windowswin2003里面安装了.net2.0、3.0、3.5。 win2008里面安装的是系统自带的.net 3.5.1过会儿我在win2008里面装下win2003的这几个个环境试试。恩 这个兴许是闭源项目的缺点,不能由自己控制。 这个项目我是临时接的,单点登录采用这种方式是之前搞的。而且接这个登录系统的其他系统,好多。不可能去再自己重新写一个。 看源码到这里,感觉不容易解决啊private static HttpCookie GetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath, bool hexEncodedTicket){ Initialize(); if (userName == null) { userName = string.Empty; } if ((strCookiePath == null) || (strCookiePath.Length < 1)) { strCookiePath = FormsCookiePath; } DateTime utcNow = DateTime.UtcNow; DateTime expirationUtc = utcNow.AddMinutes((double) _Timeout); FormsAuthenticationTicket ticket = FormsAuthenticationTicket.FromUtc(2, userName, utcNow, expirationUtc, createPersistentCookie, string.Empty, strCookiePath); string str = Encrypt(ticket, hexEncodedTicket); if ((str == null) || (str.Length < 1)) { throw new HttpException(SR.GetString("Unable_to_encrypt_cookie_ticket")); } HttpCookie cookie = new HttpCookie(FormsCookieName, str); cookie.HttpOnly = true; cookie.Path = strCookiePath; cookie.Secure = _RequireSSL; if (_CookieDomain != null) { cookie.Domain = _CookieDomain; } if (ticket.IsPersistent) { cookie.Expires = ticket.Expiration; } return cookie;} 为什么感觉不容易解决呢?之前做过将win2003中的system.web替换到win2008中的system.web,但是没有起到效用。帮忙看看,我替换的对不。C:\Windows\Microsoft.NET\Framework\v2.0.50727\system.web.dll替换到2008的C:\Windows\Microsoft.NET\Framework\v2.0.50727\system.web.dllC:\Windows\Microsoft.NET\Framework64\v2.0.50727\system.web.dll FormsAuthentication.SetAuthCookie(userName, true); 默认采用最新版本的验证数据和加密方式可改为指定版本,手动设置cookie,FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, //version userName, DateTime.Now, DateTime.Now.AddMinutes(30), false, "admins,users,xxx" ); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); System.Web.HttpContext.Current.Response.Cookies.Add(authCookie); entity framework开发模式,如何直接使用entity sql语句 求代码数组中的元素相加得出一个最接近最先给出数的值 (求助啊)搞不明白。。 请问大家,怎样实现按键加速啊? 如何将WindowsForm的Datagrid的内容更新回数据库 我用SqlCommand删除10万记录时提示"超时时间已到。在操作完成之前超时时间已过或服务器未响应" c#与数据库连接的问题 两张图片合并成一张 如何更改 C# 中的DataSet中的某个字段的长度? C#制作卡拉OK点歌系统 c#将获取的ip存到serverlist中 C# 窗体应用程序的项目如何调用WPF项目
过会儿我在win2008里面装下win2003的这几个个环境试试。恩 这个兴许是闭源项目的缺点,不能由自己控制。 这个项目我是临时接的,单点登录采用这种方式是之前搞的。而且接这个登录系统的其他系统,好多。不可能去再自己重新写一个。
private static HttpCookie GetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath, bool hexEncodedTicket)
{
Initialize();
if (userName == null)
{
userName = string.Empty;
}
if ((strCookiePath == null) || (strCookiePath.Length < 1))
{
strCookiePath = FormsCookiePath;
}
DateTime utcNow = DateTime.UtcNow;
DateTime expirationUtc = utcNow.AddMinutes((double) _Timeout);
FormsAuthenticationTicket ticket = FormsAuthenticationTicket.FromUtc(2, userName, utcNow, expirationUtc, createPersistentCookie, string.Empty, strCookiePath);
string str = Encrypt(ticket, hexEncodedTicket);
if ((str == null) || (str.Length < 1))
{
throw new HttpException(SR.GetString("Unable_to_encrypt_cookie_ticket"));
}
HttpCookie cookie = new HttpCookie(FormsCookieName, str);
cookie.HttpOnly = true;
cookie.Path = strCookiePath;
cookie.Secure = _RequireSSL;
if (_CookieDomain != null)
{
cookie.Domain = _CookieDomain;
}
if (ticket.IsPersistent)
{
cookie.Expires = ticket.Expiration;
}
return cookie;
}
为什么感觉不容易解决呢?之前做过将win2003中的system.web替换到win2008中的system.web,但是没有起到效用。帮忙看看,我替换的对不。
C:\Windows\Microsoft.NET\Framework\v2.0.50727\system.web.dll
替换到2008的
C:\Windows\Microsoft.NET\Framework\v2.0.50727\system.web.dll
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\system.web.dll
默认采用最新版本的验证数据和加密方式
可改为指定版本,手动设置cookie,FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
1, //version
userName,
DateTime.Now,
DateTime.Now.AddMinutes(30),
false,
"admins,users,xxx"
);
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);