简体   繁体   中英

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. 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. 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

    <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). you can also set the location to an entire folder.

This should be done in we.config file. within the .

hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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