Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Code for Logout

$
0
0

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 i am not able to logout from page...

I am getting _doPostBack is undefined error....

Please send me other alternative...If i click back button also it should not show logged in pages...I have tried but not able to achieve my requirement...

Thanks in advance...


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>