如何从表单身份验证中正确注销

时间:2019-08-10 01:22:50

标签: asp.net authentication authorization forms-authentication

我有两个几乎完全相同的网站,它们都有一个受保护的Admin文件夹。 我都可以登录,但不能从站点1退出。这使我回到“登录”页面,但是我可以再次访问管理页面而不必重新登录。从站点2退出可以将我正确锁定。

我删除了cookie,重新启动了浏览器,并在其他计算机上尝试了:都是一样的。

我还能在哪里检查?

下面的示例显示了硬编码的凭据,只是无视。

if (UserEmail.Value == MyUserName & UserPass.Value == MyPassword)
{
    FormsAuthentication.SetAuthCookie(UserEmail.Value, true);
    Response.Redirect("AdminHome.aspx");
}
else
    Msg.Text = "Please try again.";

void Signout_Click(object Src, EventArgs E)
{
    FormsAuthentication.SignOut();
    Response.Redirect("Login.aspx");
}

 ------- web.config ------
<system.web>
  <authentication mode="Forms">
    <forms loginUrl="~/adminfolder/Login.aspx" name=".ASPXFORMSAUTH" slidingExpiration="true"  timeout="10000"></forms>
  </authentication>
  <authorization>
  </authorization>
</system.web>

<location path="adminfolder">
  <system.web>
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>
</location>

0 个答案:

没有答案