[英]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. 我有一个网页,显示可以编辑的DB值(网格视图)。 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.
我的问题是:编辑后如果我注销该页面,它将注销我,但是如果我再次在浏览器中输入该页面URL,则该页面将再次加载而不是要求我再次登录。
ASP.NET Code: ASP.NET代码:
<%@ 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: C#代码:
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.
因此,您必须在页面加载Page_load上添加一条语句。 If(ispostback) Responce.redirect(login.aspx) Or if ( ! Ispostback) im not sure which one
If(ispostback)Responce.redirect(login.aspx)还是if(!Ispostback)不知道是哪一个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.