I just tried an experiment and was suprised by the results. I logged into my website and navigated to my pages. I then opened a new tab on the browser and entered the URL of my website. The following happened that I cannot explain. I was hoping to get
an explanation here.
I expected that I would have to log in, in the user tab. Instead I was directed to my startup page. I am not sure why?
The session variables that I created in my login page were available in the tabbed page even though I skipped the login.
In the tabbed session the treeview control was opened to the same node as the originally logged in page instead of being in its default collapsed state.
I expected that I would have to log in, in the user tab. Instead I was directed to my startup page. I am not sure why?
The session variables that I created in my login page were available in the tabbed page even though I skipped the login.
Opening new tab will use same cookie as original page, allowing ASP.NET to use the existing session. But you can detect new tab having same session by checking like this in Page_Load..
if (!Session.IsNewSession && Request.UrlReferrer == null)
{
// old session but new tab or window
}
I expected that I would have to log in, in the user tab. Instead I was directed to my startup page. I am not sure why?
The session variables that I created in my login page were available in the tabbed page even though I skipped the login.
Opening new tab will use same cookie as original page, allowing ASP.NET to use the existing session. But you can detect new tab having same session by checking like this in Page_Load..
if (!Session.IsNewSession && Request.UrlReferrer == null)
{
// old session but new tab or window
}
Thanks for the information. I was wondering if putting the following code in a base's onLoad event would make sense in order to force the user to log in the tabbed session.
if (!Session.IsNewSession && Request.UrlReferrer == null)
{
FormsAuthentication.Signout();
FormsAuthentication.RedirectToLoginPage();
}
Would this create separate sessions between the two tabs?
Would this create separate sessions between the two tabs?
Yes, it should. But it will clear session for the main tab also. Keep in mind, sharing session between tabs is standard behavior for most of internet sites.
Would this create separate sessions between the two tabs?
Yes, it should. But it will clear session for the main tab also. Keep in mind, sharing session between tabs is standard behavior for most of internet sites.
NewToDotNet
Participant
1052 Points
734 Posts
Shared Sessions between different tabs on the browser
Dec 16, 2011 07:44 PM|LINK
I just tried an experiment and was suprised by the results. I logged into my website and navigated to my pages. I then opened a new tab on the browser and entered the URL of my website. The following happened that I cannot explain. I was hoping to get an explanation here.
Thanks
budugu
All-Star
41132 Points
6021 Posts
Re: Shared Sessions between different tabs on the browser
Dec 16, 2011 07:59 PM|LINK
Opening new tab will use same cookie as original page, allowing ASP.NET to use the existing session. But you can detect new tab having same session by checking like this in Page_Load..
if (!Session.IsNewSession && Request.UrlReferrer == null) { // old session but new tab or window }"Don't be afraid to be wrong; otherwise you'll never be right."
NewToDotNet
Participant
1052 Points
734 Posts
Re: Shared Sessions between different tabs on the browser
Dec 16, 2011 08:08 PM|LINK
Thanks for the information. I was wondering if putting the following code in a base's onLoad event would make sense in order to force the user to log in the tabbed session.
if (!Session.IsNewSession && Request.UrlReferrer == null)
{
FormsAuthentication.Signout();
FormsAuthentication.RedirectToLoginPage();
}
Would this create separate sessions between the two tabs?
Thanks
budugu
All-Star
41132 Points
6021 Posts
Re: Shared Sessions between different tabs on the browser
Dec 16, 2011 08:19 PM|LINK
Yes, it should. But it will clear session for the main tab also. Keep in mind, sharing session between tabs is standard behavior for most of internet sites.
"Don't be afraid to be wrong; otherwise you'll never be right."
NewToDotNet
Participant
1052 Points
734 Posts
Re: Shared Sessions between different tabs on the browser
Dec 17, 2011 03:39 PM|LINK
Thanks for the help.