zoukankan
html css js c++ java
FormsAuthentication最简单的使用
登录
protected
void
btnLogin_Click(
object
sender, EventArgs e)
{
string
userName
=
"
UserName
"
;
string
password
=
"
Password
"
;
if
(txtUserName.Text
==
userName
&&
txtPassword.Text
==
password)
{
setValidTime(chkRememberMe.Checked, userName);
Response.Write(
"
<script>top.location='Default.htm';</script>
"
);
}
else
{
labMsg.Text
=
"
登录失败,请重试
"
;
}
}
/**/
///
<summary>
///
设置有效时间
///
</summary>
protected
void
setValidTime(
bool
RememberMe,
string
strUserName)
{
if
(RememberMe)
{
FormsAuthentication.SetAuthCookie(strUserName,
true
);
HttpCookie lcookie
=
Context.Response.Cookies[FormsAuthentication.FormsCookieName];
lcookie.Expires
=
DateTime.Now.AddYears(
1
);
}
else
{
FormsAuthentication.SetAuthCookie(strUserName,
false
);
}
}
注销
protected
void
btnSignOut_Click(
object
sender, EventArgs e)
{
FormsAuthentication.SignOut();
}
查看全文
相关阅读:
如何获得浏览器localStorage的剩余容量
按Enter键后Form表单自动提交的问题
IE10 11的css hack
text-transform设置单词首字母大写
Jade模板引擎(一)之Attributes
sql server之ROW_NUMBER() OVER()取每组的第N行数据
CSS3之让背景图片全部显示
摆脱npm的网络问题: 淘宝npm镜像
MaskedTextBox的聚焦和光标位置
将博客搬至CSDN
原文地址:https://www.cnblogs.com/yvesliao/p/889058.html
最新文章
Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 1)
Codeforces Global Round 1
Codeforces Round #534 (Div. 1)
[SDOI2010] 猪国杀
CodeForces 1105E
Codeforces Round #532 (Div. 2)
[NOI2005]维护数列
Codeforces Round #531 (Div. 3)
Atcoder Educational DP Contest
likely,unlikely宏与GCC内建函数__builtin_expect()
热门文章
[转]Google gflags使用说明
[转]Google 的开源技术protobuf 简介与例子
Linux的日志错误级别
nginx+lua_module安装
Mac下Lua环境搭建
【leetcode】500. Keyboard Row
[LeetCode] Binary Watch 二进制表
C++ bitset类的使用与简介 [转载]
【leetcode】448. Find All Numbers Disappeared in an Array
windows环境下无法引用全局安装的模块问题
Copyright © 2011-2022 走看看