Form验证基础

1.项目跟目录下web.config

    <authentication mode="Forms">
      <forms protection="All" timeout="200" name="xxx" loginUrl="~/admin/Login.aspx">
      </forms>
    </authentication>

2.需要验证的目录下的web.config

<?xml version="1.0"?>
<configuration>
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
</configuration>

3.将相关信息放到Session中,设置Cookie

Session["ad"] = admin;
AdminManager.Updatetime(admin);
FormsAuthentication.SetAuthCookie(name, false);

 

4.退出认真

FormsAuthentication.SignOut();
 

posted @ 2012-02-10 15:15  Xyang  阅读(165)  评论(0编辑  收藏  举报
hi