Step1->The best way to add logout button in your master page instead of each page in your application
Demonstration:- <asp:LinkButton ID="lnk" runat="server" Text="Logout" ForeColor="white"
Step2-> Now remove the session from cache, To do it, write the following code in page_load event of your master page in which you have logout button.
protected void Page_Load(object sender, EventArgs e)
Step3-> Now write the following code in click event of link button
protected void lnk_Click(object sender, EventArgs e)
After performing all these steps your logout button will perform fine,
If you want to make more secure of your web application then you need to add Global.asax file in your web application. We define an event in this file that will perform globally and provide security from intruders.
Step1-> *Right click on your web application .
*Add new item.
*Add Global.asax file.
Step2-> Write a function in your Global.asax file as mention below.
if (Session["usr"] == null)
//Here you can write the address of your home page or index page
// Or which you want to make start page.
Now your web application is secure. If any one paste the url of any page of your web application in the browser but browser will show only home or index page of your web application insteade of appropriate page. This is because your Global.asax file that works globally.
<a herf=" http://aspnet-with-c-sharp.blogspot.com/"> Logout button in your web application</a>