web.config配置的验证级别
2015-11-04 11:57
393 查看
应用情景---需要登录的网站,用户需登录之后才能到达其他的页面。
login界面中三个控件,用户名和密码输入框,提交按钮。
web.config中配置:
在login.aspx.cs登录按钮事件中插入:
login界面中三个控件,用户名和密码输入框,提交按钮。
web.config中配置:
<configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <authentication mode="Forms"> <forms name="myCookie" loginUrl="login.aspx"> </forms> </authentication> <authorization> <deny users="?"/> </authorization> </system.web> </configuration>
在login.aspx.cs登录按钮事件中插入:
if (Text1.Value == "mr" && Text2.Value == "mrsoft") { FormsAuthentication.SetAuthCookie(Text1.Value.Trim(), false); Response.Write("<script>alert('登录成功!');location.href='Default.aspx';</script>"); } else { Response.Write("<script>alert('登录失败!');</script>"); }
相关文章推荐
- 计算几何专题
- 手机wifi密码的保存位置
- keepalive + Nginx实现高可用性及负载均衡
- 基于JavaScript实现移动端点击图片查看大图点击大图隐藏
- js数组去重的5种算法实现
- 应用Druid进行数据源、SQL、Web应用、URI、Session等监控的简单实现
- HDOJ 题目1892 See you~(二维树状数组)
- 第九章:对Ajax的支持——深入浅出学Spring Web MVC
- 升级python到2.7 安装setuptoolos mysqldb
- Java replace & replaceAll
- Model View Controller (MVC) Overview
- appium + python 环境搭建
- 常用接口定义02——DB与DR系列端口
- Oracle客户端显示乱码解决
- 第八章:拦截器——深入浅出学Spring Web MVC
- 访问系统相册
- 比较特殊的页面效果
- 拆分Spring配置文件
- iOS 多线程的解决方案
- 正则表达式入门