簡體   English   中英

使用ASP.net中的表單身份驗證注銷后可以訪問頁面

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

我正在使用表單身份驗證進行用戶身份驗證。 使用登錄憑據登錄到default.aspx頁面后,從default.aspx頁面退出並重定向到login.aspx頁面。 之后,如果我嘗試通過直接從IE地址欄中選擇來加載頁面default.aspx頁面,則可以使用以前的憑據加載該頁面。 這是退出代碼,

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

這是web.config中的身份驗證部分

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

這是過程,

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>

這將拒絕該頁面中的匿名用戶(Default.aspx)。 您還可以將位置設置為整個文件夾。

這應該在we.config文件中完成。 在。

希望這可以幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM