• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1890
  • Last Modified:

how to count the number of browser tabs are opened for an application?

Hai,
  I had developed a web application in C#ASP.net 1.1.In my application there are several pages
 The user can login from different pages of my application.I had passed the username between the pages using session variables.
 My problem is, When the user opens my application in different tabs and the user got login in one tab of the browser and another tabs are remain in "YOU ARE SIGNED IN AS GUEST" and the user now clicks login page in that another tabs it shows like "YOU ARE ALREADY SIGNED IN"
  how to prevent this type of problem?
  Is it possible,to count the number of tabs are opened for my application in that browser?
Plz give me a solution to solve this problem.........
0
Nissiinfotech
Asked:
Nissiinfotech
2 Solutions
 
aymoon80Commented:
Hi,
>>and another tabs are remain in "YOU ARE SIGNED IN AS GUEST" and the user
>>now clicks login page in that another tabs it shows like "YOU ARE ALREADY SIGNED IN"

the problem is not clear for me, please clarify
0
 
NissiinfotechAuthor Commented:
Hai,
   For example if The user opens two tabs in same browser and opens opens my application in that two tabs.
  In first tab,the user got signed in and now he looks the second tab in that the user found that,"YOU ARE SIGNED IN AS GUEST".In second tab,the user clicks the login page it shows that "YOU ARE ALREADY SIGNED IN"  
  This is my problem,if it is guest means,the user needed to signin but it shows "YOU ARE ALREADY SIGNED IN"  
  how to prevent this problem?
Send some sample code to solve this problem.
Plz give a solution to solve this problem......
0
 
tsqlguyCommented:
The most probable issue is that on your pageload event you are not checking for
if (Session.IsNewSession == true)
{
    if (Session["SessionID"].ToString() != "")
    {
        //load user info here and set up page as logged in.
    }
}

If you are persisting variables through session variables they will persist from tab to tab and you will not have this issue. Otherwise if you're not checking on the page load event and setting up your page based on this, you will not show as logged in.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
amar31282Commented:
tsqlguy is correct....


the issue is not with tabs .

Infact there is no issue at all. you are just confused .. let me explain..

When you open multiple tabs in browser (in guest mode i.e. without login) all the tabs make there View State and they show the not logged in message.

But when you login into any one the tab then in that case in actual you have logged in for all the tabs/pages but since they won't know this thing automatically that the login session has been created and so they won't show up the logged in message......

you just need to refresh all other tabs once you have signed in using any one of the tabs so that they can know that the login session has been started..


Regards,
Amarjit
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply

   The above solution is applicable for my application.I had sented the last page url using session this will redirect the page where the user lastly from.
  My problem is I had checked like "Response.Redirect(Session["LastPage"].ToString());" this redirect the page lastly from.There occurs a confilct that is if the user open my application in two different tabs in same browser with different pages. If the user opens second tab last with out signin in any tabs.and the user signin in first tab the gots the page in the second tab.but I needed to redirect the page where the user last page in that tab itself

for example, the user opens my application in two tabs of the same browser without signin with different pages, Page A in first tab and Page B in second tab,the page in the second tab is the last opened page.Now the user got signin in first tab and it redirects to Page B.I needed that it should redirect to Page A where last page shown in that tab.

Plz send some sample code to solve this problem........      
0
 
amar31282Commented:
sounds strange ...!

Can u attach some code
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply

  My problem is the user opens my application in two tabs of same browser.In first tab,user in Page A.In second tab,user in Page B.In the Page A and Page B I had used a session variable with the last page URL.
   "Session["LastPage"]=Request.Url;".The last page opened is Page B.
My problem is Now the user going to signin in the first tab,the user got signin and the user got the Page B instead of Page A.
   In login page,I had redirect the last page using this code,"Response.Redirect(Session["LastPage"].ToString());"
 How to solve this type of problem?
Plz send some sample code to solve this problem.........
0
 
amar31282Commented:
r u trying to achieve something like the Redirect Url  like  ASP.Net Authentication Redirect after login ...


Do u want to redirect the user to the last page they were trying to access after login...


it would be better if you post your code and then i can modify it for correct functioning..

0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply

  Yes you are correct I used this code to redirect where the user lastly from "Response.Redirect(Session["LastPage"].ToString());"
   But I needed to redirect the user where the user last page in that browser tab after signin.

For example,user opens my application in two tabs of same browser.In first tab,user in Page A.In second tab,user in Page B.Last opened page is Page B.
 Now the user going to signin in the first tab,the user got signin and the user got the Page B instead of Page A. I needed to redirect to Page A.
0
 
amar31282Commented:
hmm...

in this case then you will need to put a query string in the signin page instead of the Session...

put some the token  like RedirectUrl=/lastpage.aspx and when the use loggs in from signin page it picks up the token(i.e. RedirectUrl) from query string and redirects to that page...

and if there is no RedirectUrl present then redirect to some default page for home etc...
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
  There is a UserControl in that Page A and B.The User can signin throw that usercontrol only.The Usercontrol is a javascript js page.code is "document.write('<a href="Login.aspx" class="menu" onmouseover=showToolTip(event,2);return false onmouseout=hideToolTip()>Sign In</a>');"

How can I pass the last page throw it for the above problem?

Plz send some sample code..........
0
 
amar31282Commented:
can u post the code.. for page and control u r using
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
  There is a UserControl in that Page A and B.The Usercontrol does not have any code .In .js Page the code is "document.write('<a href="Login.aspx" class="menu" onmouseover=showToolTip(event,2);return false onmouseout=hideToolTip()>Sign In</a>');"
  In the Page A and Page B I had used a session variable with the last page URL.This code gets the URL
   "Session["LastPage"]=Request.Url;".
I used this code to redirect where the user lastly from "Response.Redirect(Session["LastPage"].ToString());"

Plz send some sample code..........
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
  There is a UserControl in that Page A and B.The Usercontrol does not have any code .In .js Page the code is "document.write('<a href="Login.aspx" class="menu" onmouseover=showToolTip(event,2);return false onmouseout=hideToolTip()>Sign In</a>');" .This .js page is called in usercontrol.
  In the Page A and Page B I had used a session variable with the last page URL.This code gets the URL
   "Session["LastPage"]=Request.Url;".
I used this code to redirect where the user lastly from "Response.Redirect(Session["LastPage"].ToString());"

Plz send some sample code..........
0
 
NissiinfotechAuthor Commented:
Hai,
  Thanks for your reply
  I got my solution.I had passed the url string in that .js page like this  1st line
"var a=window.location.href;"  2nd line  "document.write('<a href="Login.aspx?val='+a+'" class="menu" onmouseover=showToolTip(event,2);return false onmouseout=hideToolTip()>Sign In</a>');"

So Thanks for your reply........
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now