ASP.net的Login控件(zhuan)

 

2009-07-09 17:10

名字就是ASP.Login,在这个控件中有两个常用的Event, OnAuthenticate就是核实登录密码的,OnLoggedIn 就是管理登录后的事,比如Cookies,跳转到页面等等。
页面布置都放在下面的<LayoutTemplate>之中, 登录时候点击的按钮要声明,CommandName="Login" 这样按钮就和前面的事件联系起来了。此外,在OnAuthenticate的事件响应中,Argument是AuthenticateEventArgs,把这个变量的e.Authenticated属性设置为True,就可以标志用户已经进入系统的。反之,就是被拒绝。
在网页中,用this.User.Identity.IsAuthenticated来检查用户的Login状态。

asp.net login control
1. event OnAuthenticate: check login name and password, if ok, set e.Authenticated to true
protected void Login_User_Authenticate(object sender, AuthenticateEventArgs e)
{
bool Authenticated = false;
string compoundName = ConvertUserName(this.Login_User.UserName);
Authenticated = AuthenticateUser(compoundName, this.Login_User.Password);
e.Authenticated = Authenticated;
}
2. event OnLoggedIn
check if remember me on this computer. If it is, set cookies
3.<LayoutTemplate>
customerize login control. Do whatever you like but use the specified user id and command name.
UserName
Any control that implements IEditableTextControl, including TextBox, or a custom or third-party control.
Required
Password
Any control that implements IEditableTextControl, including TextBox, or a custom or third-party control.
Required
RememberMe
CheckBox
Optional
FailureText
Any control that implements ITextControl.
Optional
Login
Any control that causes event bubbling.
Optional
4. In web.config
from the root directory
<location path="FolderName">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
from root<configure> -> System.Web
<authentication mode="Forms">
<forms name=".ASPXADBARGAINS" defaultUrl=&quot;Default.aspx" loginUrl="~/Public/LoginUser.aspx">
</forms>
</authentication>

转载于:https://www.cnblogs.com/pursue/archive/2009/09/15/1566929.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值