找到解决的方法是:authCookie.Expires = authTkt.Expiration;
http://dotnet.org.za/thea/archive/2004/07/27/3010.aspx
I'm using Forms Authentication and Role based security for an app I'm working on. Ran into a problem that even though I set the IsPersistent parameter of the FormsAuthenticationTicket to true, next time I open the app I have to log in again...
authTkt =
new FormsAuthenticationTicket(1, userId, DateTime.Now, DateTime.Now.AddYears(1), true, userRoles);Well, doh, the plain and simple answer is that you need to set the expiry date of the cookie, otherwise it expires when the user closes the browser. Problem solved :-)
authCookie.Expires = authTkt.Expiration;
More info on ASP.Net cookies on CodeProject.

# region 方法:string TransString(string, int)按字符串的实际长度截取定长字符串
public static string TransString(string Str,int Length)

{
int i = 0, j = 0;
foreach (char Char in Str)

{
if ((int)Char > 127)
i += 2;
else
i ++;
if (i > Length)

{
Str = Str.Substring(0, j) + "
";
break;
}
j ++;
}
return Str;
}
# endregion按位截取字符,会有半个位留下的情况

string GetSubString(string origStr,int endIndex)
{
byte[] bytes=System.Text.Encoding.GetEncoding("gb2312").GetBytes(origStr);
if(endIndex>=bytes.Length)
return origStr;
byte[] subBytes=new byte[endIndex];
Array.Copy(bytes,0,subBytes,0,endIndex);
return System.Text.Encoding.GetEncoding("gb2312").GetString(subBytes);
}
绑定xml的内容和属性
http://weblogs.asp.net/sonukapoor/archive/2004/05/10/129215.aspx