您的位置:首页 - 教程 - ASP.NET - 正文
怎样设置Request.IsAuthenticated为true
How to set Request.IsAuthenticated to true when not using FormsAuthentication.RedirectFromLoginPage?

把Request.IsAuthenticated设置为true的方法有:FormsAuthentication.RedirectFromLoginPage以及FormsAuthentication.SetAuthCookie

具体为:
FormsAuthentication.SetAuthCookie("hovertree",false);

FormsAuthentication.Authenticate("hovertree", "hewenqi");

其中hovertree为用户名,hewenqi为密码

还有一种方法:
FormsAuthentication.RedirectFromLoginPage("hewenqi", false);

其中hewenqi为用户名

需要设置web.config
<system.web><authentication mode="Forms">
<forms loginUrl="/htpl/ulogin.aspx" defaultUrl="/htpanel/">
<credentials passwordFormat="MD5">
<user name="hewenqi" password="307384E36ABBB53664ECE5DA056E8397"/>
</credentials>
</forms>
</authentication></system.web>

评论: