Problem in logging Out
-
hello friends, In my app, i have a logout buton for which i have written the following code. Session.Remove("UserID"); Session.RemoveAll(); Session.Abandon(); Response.redirect("home.aspx"); But when i press logout button i come back to the last page. that should not be happen bcoz i am having a logincheck usercontrol on that page that cheks wheither Session("UserID") is null or not.......
Deepak Nigam
-
hello friends, In my app, i have a logout buton for which i have written the following code. Session.Remove("UserID"); Session.RemoveAll(); Session.Abandon(); Response.redirect("home.aspx"); But when i press logout button i come back to the last page. that should not be happen bcoz i am having a logincheck usercontrol on that page that cheks wheither Session("UserID") is null or not.......
Deepak Nigam
As per your comments When User clicks log out button you are clearing Session and redirecting user to Home Page this what you have implemented ... But it is behaving relatively against it
Deepak Nigam wrote:
But when i press logout button i come back to the last page.
How are you going again back to last page ? If you saying by clicking back Button then Page might be coming from browser Cache
Deepak Nigam wrote:
bcoz i am having a logincheck usercontrol on that page that cheks wheither Session("UserID") is null or not.......
As Good practice you should check user credentials in every page By creating a base which will check User Credentials in every Page LOad This Page need extend from System.Web.UI.Page and your all Page should extends this Page
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
As per your comments When User clicks log out button you are clearing Session and redirecting user to Home Page this what you have implemented ... But it is behaving relatively against it
Deepak Nigam wrote:
But when i press logout button i come back to the last page.
How are you going again back to last page ? If you saying by clicking back Button then Page might be coming from browser Cache
Deepak Nigam wrote:
bcoz i am having a logincheck usercontrol on that page that cheks wheither Session("UserID") is null or not.......
As Good practice you should check user credentials in every page By creating a base which will check User Credentials in every Page LOad This Page need extend from System.Web.UI.Page and your all Page should extends this Page
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
I come back to last page by clicking the Back button on the browser.
Deepak Nigam
-
I come back to last page by clicking the Back button on the browser.
Deepak Nigam
Deepak Nigam wrote:
I come back to last page by clicking the Back button on the browser.
This will come from Cache. If you are checking the Credentials in every page then this should not cause any problem. e.g If user is in My Application Page where there are many controls like buttons etc to retrive some data. Now if i click Sign Out from this Page I will get redirect to Home Page ok Its fine Now When user click back button browser will show My Application Page from Cache . Now if User clicks any server control in that page like button now Page Load will occure if you are checking Any user Credentials in My Application Page User wont be able to do anything he will get redirected to Home Page So its better to create a base class that will check user Credentials in its Page Load(What you are doing in user control) and your pages should extent this base page Any how if you don't want ot Cache your page you will have to write this lines Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time Add at the every page
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Deepak Nigam wrote:
I come back to last page by clicking the Back button on the browser.
This will come from Cache. If you are checking the Credentials in every page then this should not cause any problem. e.g If user is in My Application Page where there are many controls like buttons etc to retrive some data. Now if i click Sign Out from this Page I will get redirect to Home Page ok Its fine Now When user click back button browser will show My Application Page from Cache . Now if User clicks any server control in that page like button now Page Load will occure if you are checking Any user Credentials in My Application Page User wont be able to do anything he will get redirected to Home Page So its better to create a base class that will check user Credentials in its Page Load(What you are doing in user control) and your pages should extent this base page Any how if you don't want ot Cache your page you will have to write this lines Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time Add at the every page
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
Thanks Sandeep.......... It works.
Deepak Nigam