Click here to Skip to main content
13,596,321 members
Rate this:
Please Sign up or sign in to vote.
See more:
i have one query about

i created one application in two webforms login.aspx and home page.aspx and i run this application into browser.When i successfully login then it i will direct to Home page and showing welcome Username(By using Session). whenever i copy the url and paste it into another tab of that browser the same homepage is shown but my requirmnet is it should be redirected login page instead of Home pAge.

So please suggest How to handle the session in this case !!!!
Posted 14-Feb-13 21:55pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It doesn't work that way - the login info is normally saved in the Cookies which are stored on the client PC - so if he opens a new window without logging out or closing his browser then he remains logged in.

You would either have to store the login in the Sesssion and check it from there (which is unique to the browser tab) or add and check the session ID when you do teh login check. Boith of these will probably mean implementing a custom Membership Provider - which isn't too difficult if (as I assume) you are using Membership already. MSDN can help:[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Hope this will help you..

protected void Page_Load(object sender, EventArgs e)
     if (!this.IsPostBack)
         if (Request.UrlReferrer == null)

If you copy paste the url in another tab means there is no previous page. So if no previous page reference this code will redirect to login page.
vinodkumarnie 15-Feb-13 4:26am
You put this in your home page..
Reshma89 15-Feb-13 4:43am
Thank u so much......
vinodkumarnie 15-Feb-13 4:54am
Welcome.. Please rate the answers.. It will help us.. Thank u..
Reshma89 15-Feb-13 8:32am
one more query related to this
when i successfully login it should redirect to home.aspx then i copied the home page url then go to back by using back option of the browser then it should redirect to login page then i paste it homepage url what i copied as before that contains previous page then this code got failed ....
plz suggest what i can do
vinodkumarnie 15-Feb-13 22:41pm
after copy paste what you want to do..? how it should work..?
Reshma89 18-Feb-13 6:04am
i mean when i copy the homepage URL then i did not paste it in a new browser rather i paste it in existing login address url
Below is my Observation
when i paste in new tab no doubt the back option of the broswer is disable but whenever i paste on existing tab of the browser the condition will not satisfied
if (Request.UrlReferrer == null)
make it correct if i am wrong
So plz suggest what i can do....
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

this can be done by the session
if the user's authentication is right in login page then you can match session at home page.
i will give you example if right login at login page then pass session

 Session["user"] = txtuser.Text;

and in home page check the user authentication

Labeluser.Text = Session["user"].ToString();
                str = "select * from login where username='" + Labeluser.Text + "'";
                cmd = new OleDbCommand(str, Classcon.con);
                dtp = new OleDbDataAdapter(cmd);
                ds = new DataSet();
                if (ds.Tables[0].Rows.Count == 0)
                    // Response.Redirect("adminhome.aspx");

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.180621.3 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100