user should not login again if he is loggedin once during same browser [modified]
-
hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.
modified on Saturday, March 27, 2010 5:02 AM
-
hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.
modified on Saturday, March 27, 2010 5:02 AM
To remove "object reference not set to an instance of an object" error, you should check whether the session object is null before accessing Session["customer"] object.
Thanks, Arindam D Tewary
-
hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.
modified on Saturday, March 27, 2010 5:02 AM
try at the Page_load , first thing in ur page if (Session["customer"] == null) { Response.Redirect("URLOGINPAGE.aspx"); } this way, if the user still didnt logout, he will still have access to those secured pages without entering the login page again. till he logout
-
hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.
modified on Saturday, March 27, 2010 5:02 AM
Session variables are not shared from window to window like that. If using forms authentication, this is what you are looking for.
if (this.User.Identity.Name == "Admin") { Response.Redirect("Admin/AdminHome.aspx", false); }
Normally you would do this the other way around. If the user tried to access AdminHome without being logged in, send them to the login and bounce them back from there if successful login.
-
Session variables are not shared from window to window like that. If using forms authentication, this is what you are looking for.
if (this.User.Identity.Name == "Admin") { Response.Redirect("Admin/AdminHome.aspx", false); }
Normally you would do this the other way around. If the user tried to access AdminHome without being logged in, send them to the login and bounce them back from there if successful login.
thanks you very much sir for your support, i have an another issue.please suggest me.what should i do. when ever i am entering my url in browser ie and login page will display and i am doing successfull login.and now when i opened new browser and enter url it will show direct user home.it is absolutely right.but now sir when i am entering my url in mozilla or new browser.it should not show user home.it should show login page.but it shows user home. if you will try for gmail through ie.after login if you will open new gmail in mozilla it will not show inbox page while it will show login page. please suggest me how i can resolve this issue.
-
thanks you very much sir for your support, i have an another issue.please suggest me.what should i do. when ever i am entering my url in browser ie and login page will display and i am doing successfull login.and now when i opened new browser and enter url it will show direct user home.it is absolutely right.but now sir when i am entering my url in mozilla or new browser.it should not show user home.it should show login page.but it shows user home. if you will try for gmail through ie.after login if you will open new gmail in mozilla it will not show inbox page while it will show login page. please suggest me how i can resolve this issue.
Gmail - Your assumptions are not accurate. If you do not 'sign out' of gmail in mozilla, it will open the inbox page. Same with IE. IE and mozilla operate completely independant of each other. This behavior is usually acceptable. Assuming you are using the aspnet membership provider, you can test 'signout' functionality using
FormsAuthentication.SignOut();
. Anytime the signout is used, I also kill the session usingSession.Abandon();
. The membership provider behaves similar to gmail if that is the desired result.