You mentioned
"when i press logout button i redirected succesfully to main login page clearing the session values but when paste the url of default2.aspx page, my application just enters the page without any session value errors,even the page_load function doesn't run where i can check if session has some values."
Are you checking for session variable on that page ?
Let say, you have session Variable
Session["UserName"] = "Something"
. When you do call
Session.Abandon()
, it destroy the all session object. So
Session["UserName"]
became null.
What you need to check in your
Page_Load(
) is
if(Session["UserName"] != null )
{
}
else
{
}
for generic implementation create a Base Page Class with all the global validation related checks and inherited other page from global base page, so you do not need to write this logic for all pages !
If you really interested to look how session clears session variable, have a look
ASP.NET Internals : “Clearing ASP.NET Session Variables” a in-depth look[
^]
Hope this will help !