62,047
社区成员
发帖
与我相关
我的任务
分享
<authentication mode="Forms">
<forms defaultUrl="~/login.aspx" domain=".test.com" slidingExpiration="true"></forms>
</authentication>
<machineKey
validationKey="969CDD5D85E13827ADFF3E80771472F11B3D454930D39DA19399AB714F596CA98B2D10D47E911990E2491211550E42FE676859CD4925F4028076DD6262A62F80"
decryptionKey="5300D71269AC1D709C42E1A96E636EED0ABFF655C05CAEB6C64BA9EAEF9A88C3"
validation="SHA1" decryption="AES" />
<authorization>
<deny users="?"/>
</authorization>
<httpCookies domain=".test.com"/>
System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, "UserId", DateTime.Now, DateTime.Now.AddMinutes(30),
false, "teacher");
string EncrTicket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
HttpCookie myCookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, EncrTicket);
System.Web.HttpContext.Current.Response.Cookies.Add(myCookie);
<authentication mode="Forms">
<forms domain=".test.com" slidingExpiration="true"></forms>
</authentication>
<machineKey
validationKey="969CDD5D85E13827ADFF3E80771472F11B3D454930D39DA19399AB714F596CA98B2D10D47E911990E2491211550E42FE676859CD4925F4028076DD6262A62F80"
decryptionKey="5300D71269AC1D709C42E1A96E636EED0ABFF655C05CAEB6C64BA9EAEF9A88C3"
validation="SHA1" decryption="AES" />
<authorization>
<allow users="?"/>
</authorization>
<httpCookies domain=".test.com"/>
Label1.Text = "用户是否已经进行了身份验证:" + HttpContext.Current.User.Identity.IsAuthenticated.ToString() + "<br />";
Label1.Text += "一共有" + Request.Cookies.Count.ToString() + "个cookies<br />";
for (int i = 0; i < Request.Cookies.Count; i++)
{
Label1.Text += "Name:" + Request.Cookies[i].Name + "<br />";
Label1.Text += "Value:" + Request.Cookies[i].Value + "<br /><br />";
}