Results 1 to 11 of 11

Thread: Prevent Back button on the browser

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Prevent Back button on the browser

    Hello There,i just like to ask if you have any idea of preventing the Back button of the browser to navigate back to the previous page after a user log in.

    Ex:After a user successfully logged in to my website and he/she hit the Back button of the browser.I want this to not redirected to the previous page instead redirected to the same page which is my Main page.Also after a user logged out to my website and again he/she hit the Back button of the browser.I also want this to not redirected to the previous page instead redirected to my login page.

    hope you get my point..

    Thank you very much in advance..BTW,im using C#

    glen

  2. #2
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Prevent Back button on the browser

    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Prevent Back button on the browser

    Hey,

    The simple answer is, there is no sure fire way of preventing the user from clicking the back button. At the end of the day, it is their back button, and they can click it if they want to

    The question really is why are you wanting to prevent this?

    Is it just that you don't want the user to see the login page if they are already in? If so, there are a number of other ways of doing this.

    Gary

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: Prevent Back button on the browser

    Quote Originally Posted by gep13 View Post
    Hey,

    The simple answer is, there is no sure fire way of preventing the user from clicking the back button. At the end of the day, it is their back button, and they can click it if they want to

    The question really is why are you wanting to prevent this?

    Is it just that you don't want the user to see the login page if they are already in? If so, there are a number of other ways of doing this.

    Gary
    sorry gary if it is a little bit confusing..your right,if a user has logged in and he/she hit back button then it stays on the current page.and also if a user has logged out and he/she hit the back button then he/she redirected to the login page..thats all.

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Prevent Back button on the browser

    How are you doing your user authentication? Are you using Forms Authentication, or are you using the built in ASP.Net Membership Provider?

    Gary

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: Prevent Back button on the browser

    Quote Originally Posted by gep13 View Post
    How are you doing your user authentication? Are you using Forms Authentication, or are you using the built in ASP.Net Membership Provider?

    Gary
    yes,gary i am using Forms Authentication.

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Prevent Back button on the browser

    Hey,

    Have a look here:

    http://www.devhood.com/tutorials/tut...tutorial_id=85

    Notice how you can provide a default url to the login page, when "protected" pages are attempted to be accessed? also, how you can make pages only availalble to certain users, i.e. authenticated, anonymous, etc.

    Gary

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: Prevent Back button on the browser

    Hi Gary,are u sure that this is not a dead link?..because i cant browse it here in the office..

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Prevent Back button on the browser

    Nope, it works fine for me.

    I am looking at the page just now.

    What about these:

    http://ondotnet.com/pub/a/dotnet/200...rmsauthp1.html
    http://www.15seconds.com/issue/020220.htm

    They are very similar.

    Gary

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: Prevent Back button on the browser

    Thanks Gary im reading it right now..

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Prevent Back button on the browser

    No probs, just post back if you have any other questions.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width