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();
}
查看全文
相关阅读:
poj_1836 动态规划
动态规划——最长上升子序列
poj_3260 动态规划
poj_3628 动态规划
动态规划——背包问题
poj_2559 单调栈
poj_3415 后缀数组+单调栈
poj_2823 线段树
poj_2823 单调队列
poj_3250 单调栈
原文地址:https://www.cnblogs.com/yvesliao/p/889058.html
最新文章
转:MVC 数据验证
jQuery解析AJAX返回的html数据时碰到的问题与解决
Realm学习总结
Perfect-Server-Swift学习记录
Swift小知识点总结
React Native使用Mobx总结
安卓模拟器添加图片
记一次更换手机号的感受
react-native-picke Cannot read property '_init' of undefined
React Native使用react-navigation时,设置navigationOptions中Static中使用this注意点
热门文章
MySQL 如何利用一条语句实现类似于if-else条件语句的判断
列举你所知道的排序方法,请写出快速排序的伪代码
List、Map、Set三个接口,存取元素时,各有什么特点?
详解Oracle DELETE和TRUNCATE 的区别
使用javascript打开链接的多种方法
mybatis13---2级缓存
mybatis12一级缓存
Mybatis中#和$的区别
Compilation failed: internal java compiler error
MyBatis动态代理查询出错
Copyright © 2011-2022 走看看