Posted on: 2/22/2014 11:56:42 AM | Views : 641

Hi Everyone,

Please help me in writing code for logout in asp.net..My webapplication is not having site.master page...
In my aspx page...
<a id="Logout" runat="server">Logout</a>
In aspx.cs page...
protected void Page_Load(object sender,EventArgs e)
{
Logout.ServerClick+=new EventHandler(btnLogout_Click);
}
protected void btnLogout_Click(object sender,EventArgs e)
{
try { Session.Abandon();
Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d); Response.Expires = -1000; Response.CacheControl = "no-cache"; Response.Redirect("index.aspx", true); } catch (Exception ex) { Response.Write(ex.Message); }
}

I have used above code in all my aspx and aspx.cs pages...But ...

Go to the complete details ...