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();