简体   繁体   中英

webpage URL bringing the page which is already logout :asp.net c# (Not back button, but the page url)

i have web page showing DB values (Grid view) which i can edit. my problem is: after editing if i logout the page,its logging me out, but if i put that page URL again in the browser, the page is loading again instead of asking me for login again.

ASP.NET Code:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Logout.master.cs" Inherits="Logout" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">

        <asp:Label ID="Label1" Text="Loggin Out Please Wait.." runat="server" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

C# code:

protected void Timer1_Tick(object sender, EventArgs e)
    {
        Session.Clear();
        Session.Abandon();
        Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();

        try
        {
            Session.Abandon();
            FormsAuthentication.SignOut();
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Buffer = true;
            Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
            Response.Expires = -1000;
            Response.CacheControl = "no-cache";
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        Response.Redirect("~/Login.aspx");
    }

On page load you have to see the page is opening for the first time..if you,redirect to login page. So you have to add a statment on page load Page_load. If(ispostback) Responce.redirect(login.aspx) Or if ( ! Ispostback) im not sure which one

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