<asp:LinkButton ID="lnklogout" CssClass="navlinks" runat="server" Text="Logout" OnClick="lnklogout_Click"></asp:LinkButton>
protected void
lnklogout_Click(object sender, EventArgs e)
{
Session.Abandon();
Session.Clear();
Session.RemoveAll();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
FormsAuthentication.SignOut();
Response.Redirect("~/Logout.aspx");
}
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeBehind="Logout.aspx.cs"
Inherits="Provider_Login.Logout"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
window.history.forward(1);
</script>
<script type="text/javascript">
function preventBack() { window.history.forward(); }
setTimeout("preventBack()",
5);
window.onunload = function () { null };
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager"
runat="server">
</asp:ScriptManager>
<div>
Please
Wait...
<asp:Timer ID="Timer1" runat="server"
Interval="1"
OnTick="Timer1_Tick">
</asp:Timer>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Provider_Login
{
public partial class Logout :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma",
"no-cache");
}
}
protected void
Timer1_Tick(object sender, EventArgs e)
{
Response.Redirect("~/Login.aspx");
}
}
}
You Can Download the Working Code From here.