简体   繁体   English

使用ASP.net中的表单身份验证注销后可以访问页面

[英]possible to access page after sign out using Forms Authentication in ASP.net

I'm using Forms Authentication for user authentication. 我正在使用表单身份验证进行用户身份验证。 After login to default.aspx page using login credentials and sign out from default.aspx page and redirect to login.aspx page. 使用登录凭据登录到default.aspx页面后,从default.aspx页面退出并重定向到login.aspx页面。 after that if I try to load the page default.aspx page by selecting directly from the IE address bar, I could load that page by using previous credentials. 之后,如果我尝试通过直接从IE地址栏中选择来加载页面default.aspx页面,则可以使用以前的凭据加载该页面。 Here is the sign out code, 这是退出代码,

protected void Signout_Click(object sender, EventArgs e)
{
    FormsAuthentication.SignOut();
    Session.Clear();
    Response.Redirect("Logon.aspx");
} 

Here is the authentication part in web.config 这是web.config中的身份验证部分

    <authentication mode="Forms">
        <forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH" protection="All" path="/" slidingExpiration="true" timeout="60">
        </forms>
    </authentication>
    <authorization>
        <deny users="?"/>
    </authorization>

Here is the process, 这是过程,

1. Login to default page using login credential
2. sign out from default page
3. select the default page directly from address bar.
<location path="Default.aspx">
    <system.web>
        <authorization>
        <deny users ="?" />
       </authorization>
    </system.web>
</location>

This denies the anonymous users from that page (Default.aspx). 这将拒绝该页面中的匿名用户(Default.aspx)。 you can also set the location to an entire folder. 您还可以将位置设置为整个文件夹。

This should be done in we.config file. 这应该在we.config文件中完成。 within the . 在。

hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM