Click here to Skip to main content
15,887,911 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a website with login option asp.net.

if i open website in two browser tabs and logged in with same user account and navigated to homescreen in both tabs , now i am logged out from one tab and again logged in same tab,after that i clicked on the second tab,

My doubt is how can i discriminate that i am sending request from first tab or second tab from code behind?

If the request is from second tab i need to navigate the application to login screen.How can i do this?
Posted

Wrong idea. The tabs belong to the client's browser, not to your site or Web application. And the tab is no different from a browser window, from the server-side perspective. The login should work regardless of the tab or window. By the way, if such discrimination was possible, it could kill you login functionality.

—SA
 
Share this answer
 
Comments
5 Sergey. I tried to explain more. :)
Sergey Alexandrovich Kryukov 26-Jun-15 9:20am    
Thank you, Tadit.
—SA
Welcome. :)
Sergey Alexandrovich Kryukov 26-Jun-15 11:06am    
Tadit,

I just got a request that you wanted to contact me directly.
You can contact me via my Web site you can find through my CodeProject profile page.

—SA
Yes I requested. I cannot see any details on your CP Profile page. It just says "No Biography provided".
Tabs in a particular browser will share the same session. So, if you are logged out in one tab, that should reflect automatically in the other tab.

That means, when you are logged out from one tab and trying to do something in other tab, that would redirect to the login screen, if you have mentioned that logic in your code to handle session out. No need to from which tab request is coming. You just need to check if session is alive or not. If alive, then do the usual thing, else redirect.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Jun-15 9:19am    
5ed.
—SA
:) Thanks Sergey.
ATHUL AC 26-Jun-15 9:21am    
@Tadit Dash: in my home page i had added the logic like
if (Session["UserID"] == null)
{
Response.Redirect("Login.aspx");
}
but the problem is that when i logout from first tab and login in again there, and after that second tab refreshed Session["UserID"] is not null so it will stay there.But i need to redirect login page .how can i achieve this??
If you are logged in again in first tab, means session is created again, which will be shared across all the tabs of that browser, which is the ideal behaviour. I don't think at this time, you should redirect user to login page from another tab as he/she is already logged in.
ATHUL AC 26-Jun-15 9:39am    
thanks for the valuable comment.If i want restrict the user from concurrent login in two tab.how can i implement here?do you have any suggestions?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900