Adding Security to an Existing Website
The procedure earlier in this article relies on using the Starter Site template as the basis for website security. If it isn't practical for you to start from the Starter Site template or to copy the relevant pages from a site based on that template, you can implement the same type of security in your own site by coding it yourself. You create the same types of pages — registration, login, and so on — and then use helpers and classes to set up membership.
The basic process is described in the blog post THE most basic way to implement ASP.NET Razor security. Most of the work is done using the following methods and properties of the WebSecurity
helper:
WebSecurty.UserExists, WebSecurity.CreateUserAndAccount. These methods let you determine whether someone is already registered and to register them.
WebSecurty.IsAuthenticated. This property lets you determine whether the current user is logged in. This is useful to redirect users to a login page if they have not already logged in.
WebSecurity.Login, WebSecurity.Logout. These methods log a user in or out.
WebSecurity.CurrentUserName. This property is useful for displaying the current user's logged-in name (if the user is logged in).
WebSecurity.ConfirmAccount. This method is useful if you set up email confirmation for registration. (Details are described in the blog post Using the confirmation feature for ASP.NET Web Pages security.)
To manage roles, you can use the Roles and Membership classes, as described in the blog entry.
最新文章
- 远程CDN加速不可用,加载本地库
- 利用gulp搭建本地服务器,并能模拟ajax
- (转)设计模式_Singleton单例模式
- arraylist与linkedlist的区别与性能测试
- VS2012解决方案的设置
- Android在Service中显示Dialog
- 打印机问题win7 和xp
- andriod arcgis保存Mapview为图片
- UIButton 内部介绍
- USACO 4.1.2 栅栏的木料
- AngularJs指令(一)
- selenium webdriver(4)---模拟鼠标键盘操作
- Visual Studio 2013如何破解(密钥激活)
- 软工+C(2017第4期) Alpha/Beta换人
- BZOJ 1923: [Sdoi2010]外星千足虫 [高斯消元XOR]
- 实体类双向映射进行Json序列化时出现无限循环的解决问题
- EBS技术开发之返利开发
- springmvc注解方式
- Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSou rce'; nested exception is javax.management.InstanceAlreadyExistsException: com.z axxer.hikari:name=dataSource,type=HikariDa
- centos下查看端口占用情况,杀死进程
热门文章
- shiro配置文件
- LeetCode(51) N-Queens
- LeetCode 304. Range Sum Query 2D – Immutable
- Python+selenium(操作隐藏元素)
- Java高级程序员面试题
- HDU-1087Super Jumping! Jumping! Jumping!
- Codevs 3409 搬礼物
- Flume+kakfa+sparkStream实时处理数据测试
- CSS介绍&;选择器&;选择器优先级
- CodeForces 597A Divisibility