asp.net 身份验证

在web.config配置文件中的<system.web>节点中添加入下节点:

<system.web>
    <authentication mode="Forms">
       <forms name="自己取个名字吧" loginUrl="你的登陆页面"></forms>
   </authentication>
</systeml.web>
 
添加这段后,如果您没有登陆的话,无论你访问那个网页,都会跳转到“你上面设置的页面(这里是登陆页面)”
在登陆按钮的单击事件中添加如下代码:
FormsAuthentication.SetAuthenCookie("用户名的值",trru(or false)),这里写true的话将会保存到cookie中,false 的话不会保存到cookie中
posted @ 2013-01-07 21:25  程序有Bug  阅读(167)  评论(0编辑  收藏  举报