Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. AutoRedirect...

AutoRedirect...

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-net
26 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awedaonline
    wrote on last edited by
    #1

    Hello everyone, How do I automatically redirect someone back to a page he/she wishes to see before taken to login or signup page? Case Study 1: I want to shop online and I was to checkout and pay for the product, but the site mandated it on me that I must register with them before I could proceed (I think it's for profile purpose) or simply sign in if I am an existing user. Then after that, I was taken back to my checkout page, made payment and went out. Case Study 2: I launched this site, view forum post and click to read one but was redirected to login/signup page. After successful login, I was automatically redirected back to the post I wanted to read. Case Study n... How can I implement same in my asp.net application? Thank you all for your usual support.

    R R J 3 Replies Last reply
    0
    • A awedaonline

      Hello everyone, How do I automatically redirect someone back to a page he/she wishes to see before taken to login or signup page? Case Study 1: I want to shop online and I was to checkout and pay for the product, but the site mandated it on me that I must register with them before I could proceed (I think it's for profile purpose) or simply sign in if I am an existing user. Then after that, I was taken back to my checkout page, made payment and went out. Case Study 2: I launched this site, view forum post and click to read one but was redirected to login/signup page. After successful login, I was automatically redirected back to the post I wanted to read. Case Study n... How can I implement same in my asp.net application? Thank you all for your usual support.

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      You may want to reword this along the lines of: How do I automatically redirect a user back to the page they wished to see after being taken to a login or signup page? If so there are a number of ways depending on how you've set it up. If, for instance, you use Forms authentication then it will handle it for you (do a search on Forms authentication). You could also use attributes to seek authentication, either using built in security or custom attributes, etc, etc. IN ohter words, you'll have to be more specific about your requirement; what have you already tried?

      Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

      A 1 Reply Last reply
      0
      • R R Giskard Reventlov

        You may want to reword this along the lines of: How do I automatically redirect a user back to the page they wished to see after being taken to a login or signup page? If so there are a number of ways depending on how you've set it up. If, for instance, you use Forms authentication then it will handle it for you (do a search on Forms authentication). You could also use attributes to seek authentication, either using built in security or custom attributes, etc, etc. IN ohter words, you'll have to be more specific about your requirement; what have you already tried?

        Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

        A Offline
        A Offline
        awedaonline
        wrote on last edited by
        #3

        Realy, I haven't tried any method. But I am using Windows authentication. I create my own user database and coded their login, signup, etc... Because this is the most convenient way I can always achieve this. Any further Ideas? Regards

        N R 2 Replies Last reply
        0
        • A awedaonline

          Realy, I haven't tried any method. But I am using Windows authentication. I create my own user database and coded their login, signup, etc... Because this is the most convenient way I can always achieve this. Any further Ideas? Regards

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          awedaonline wrote:

          Any further Ideas?

          Yes, stop reinventing the wheel. Use the built-in login controls and authentication database if necessary.


          I know the language. I've read a book. - _Madmatt

          A R 2 Replies Last reply
          0
          • A awedaonline

            Realy, I haven't tried any method. But I am using Windows authentication. I create my own user database and coded their login, signup, etc... Because this is the most convenient way I can always achieve this. Any further Ideas? Regards

            R Offline
            R Offline
            R Giskard Reventlov
            wrote on last edited by
            #5

            If everything you do is custom then I might use Attributes to decorate the master page, if you have one, or every page other than the login page if you don't that just does: 1: Is this user logged in? (Could be accomplished by populating a session variable upon successful login). 2: Yes: allow access to any page. (You could also have stored the selected page in a session variable). 3: No: redirect to login. Attributes are fairly simple to create so you can look that bit up: I'm sure there are plenty of articles on CP that will help. I'm also sure there are other ways to do this and perhaps someone else can offer further suggestions.

            Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

            A 2 Replies Last reply
            0
            • N Not Active

              awedaonline wrote:

              Any further Ideas?

              Yes, stop reinventing the wheel. Use the built-in login controls and authentication database if necessary.


              I know the language. I've read a book. - _Madmatt

              A Offline
              A Offline
              awedaonline
              wrote on last edited by
              #6

              Alright, I don't know how to achieve that. Please teach me the tricks. Note with my own created database and not aspnetdb. Thanks for your responses.

              N 1 Reply Last reply
              0
              • N Not Active

                awedaonline wrote:

                Any further Ideas?

                Yes, stop reinventing the wheel. Use the built-in login controls and authentication database if necessary.


                I know the language. I've read a book. - _Madmatt

                R Offline
                R Offline
                R Giskard Reventlov
                wrote on last edited by
                #7

                Mark Nischalke wrote:

                Yes, stop reinventing the wheel.

                That does not suit every occasion - it is wrong to tell people that. I've been on many projects where, for one reason or another, that was not considered suitable to our needs and we had to hand craft a solution that did suit.

                Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                N 1 Reply Last reply
                0
                • R R Giskard Reventlov

                  If everything you do is custom then I might use Attributes to decorate the master page, if you have one, or every page other than the login page if you don't that just does: 1: Is this user logged in? (Could be accomplished by populating a session variable upon successful login). 2: Yes: allow access to any page. (You could also have stored the selected page in a session variable). 3: No: redirect to login. Attributes are fairly simple to create so you can look that bit up: I'm sure there are plenty of articles on CP that will help. I'm also sure there are other ways to do this and perhaps someone else can offer further suggestions.

                  Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                  A Offline
                  A Offline
                  awedaonline
                  wrote on last edited by
                  #8

                  Thanks for this idea. It never came to my mind to store the selected page in a Session variable. I will do it and feedback you ASAP. I am grateful.

                  1 Reply Last reply
                  0
                  • R R Giskard Reventlov

                    If everything you do is custom then I might use Attributes to decorate the master page, if you have one, or every page other than the login page if you don't that just does: 1: Is this user logged in? (Could be accomplished by populating a session variable upon successful login). 2: Yes: allow access to any page. (You could also have stored the selected page in a session variable). 3: No: redirect to login. Attributes are fairly simple to create so you can look that bit up: I'm sure there are plenty of articles on CP that will help. I'm also sure there are other ways to do this and perhaps someone else can offer further suggestions.

                    Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                    A Offline
                    A Offline
                    awedaonline
                    wrote on last edited by
                    #9

                    Wow, I tried it but not getting it right. I declared a Session("selectedPage") = "~/page.aspx" variable under the Page_Init event of the page.aspx page. Under my masterpage, I checked : If ((Session("selectedPage").ToString() <> "")) Then Response.Redirect(Session("selectedPage").ToString()) Else Response.Redirect("~/anotherPage.aspx") End If but I as redirected to the anotherPage.aspx after succesfull login which I started by selecting the page.aspx as my startup page. What could have happened plz?

                    R 1 Reply Last reply
                    0
                    • R R Giskard Reventlov

                      Mark Nischalke wrote:

                      Yes, stop reinventing the wheel.

                      That does not suit every occasion - it is wrong to tell people that. I've been on many projects where, for one reason or another, that was not considered suitable to our needs and we had to hand craft a solution that did suit.

                      Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                      N Offline
                      N Offline
                      Not Active
                      wrote on last edited by
                      #10

                      It is the appropriate response when implementing something that is already present in the framework. In this case authentication uses a provider model that can be extended to cover extenuating circimstance so again there is no need to reinvent what has already done. Redirecting to the appropriate page i s also provided via the built-in controls and model.


                      I know the language. I've read a book. - _Madmatt

                      R 1 Reply Last reply
                      0
                      • A awedaonline

                        Wow, I tried it but not getting it right. I declared a Session("selectedPage") = "~/page.aspx" variable under the Page_Init event of the page.aspx page. Under my masterpage, I checked : If ((Session("selectedPage").ToString() <> "")) Then Response.Redirect(Session("selectedPage").ToString()) Else Response.Redirect("~/anotherPage.aspx") End If but I as redirected to the anotherPage.aspx after succesfull login which I started by selecting the page.aspx as my startup page. What could have happened plz?

                        R Offline
                        R Offline
                        R Giskard Reventlov
                        wrote on last edited by
                        #11

                        Okay@ let's pretend you have a site with a Master Page, Default.aspx, Links.aspx, Contacts.aspx and Login.aspx. The only 2 pages that anyone can see without some form of authentication are Default and Login. If they try to access any other page they get redirected to LOgin if the Session variable that tracks their status is empty. If you create an attribute that checks for their status and redirects accordingly from the Master Page that should help to solve your issue. What you will also have to do is to, for example, maybe have some code underlying a menu click option that tracks the page they were trying to get to and pass that into the session variable. See how you get on: I think you should be able to figure out the rest of it from here.

                        Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                        A 1 Reply Last reply
                        0
                        • N Not Active

                          It is the appropriate response when implementing something that is already present in the framework. In this case authentication uses a provider model that can be extended to cover extenuating circimstance so again there is no need to reinvent what has already done. Redirecting to the appropriate page i s also provided via the built-in controls and model.


                          I know the language. I've read a book. - _Madmatt

                          R Offline
                          R Offline
                          R Giskard Reventlov
                          wrote on last edited by
                          #12

                          I fully undertand all that and have used it many times. But I've also not used it because we had other concerns or design issues or plain old bloody minded architects that didn't like it. Either way it is not the answer to everything.

                          Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                          N 1 Reply Last reply
                          0
                          • A awedaonline

                            Alright, I don't know how to achieve that. Please teach me the tricks. Note with my own created database and not aspnetdb. Thanks for your responses.

                            N Offline
                            N Offline
                            Not Active
                            wrote on last edited by
                            #13

                            Start here[^] and here[^]


                            I know the language. I've read a book. - _Madmatt

                            1 Reply Last reply
                            0
                            • R R Giskard Reventlov

                              I fully undertand all that and have used it many times. But I've also not used it because we had other concerns or design issues or plain old bloody minded architects that didn't like it. Either way it is not the answer to everything.

                              Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                              N Offline
                              N Offline
                              Not Active
                              wrote on last edited by
                              #14

                              Nor is DIY


                              I know the language. I've read a book. - _Madmatt

                              R 1 Reply Last reply
                              0
                              • N Not Active

                                Nor is DIY


                                I know the language. I've read a book. - _Madmatt

                                R Offline
                                R Offline
                                R Giskard Reventlov
                                wrote on last edited by
                                #15

                                I didn't say it was. What is your problem? You're not right: it isn't the only answer and I already said that custom wasn't either.

                                Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                                N 1 Reply Last reply
                                0
                                • R R Giskard Reventlov

                                  Okay@ let's pretend you have a site with a Master Page, Default.aspx, Links.aspx, Contacts.aspx and Login.aspx. The only 2 pages that anyone can see without some form of authentication are Default and Login. If they try to access any other page they get redirected to LOgin if the Session variable that tracks their status is empty. If you create an attribute that checks for their status and redirects accordingly from the Master Page that should help to solve your issue. What you will also have to do is to, for example, maybe have some code underlying a menu click option that tracks the page they were trying to get to and pass that into the session variable. See how you get on: I think you should be able to figure out the rest of it from here.

                                  Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                                  A Offline
                                  A Offline
                                  awedaonline
                                  wrote on last edited by
                                  #16

                                  Thanks a lot. but I don't seem to understand what and how to imlement that attribute you are saying. Do you mean a property?

                                  R N 2 Replies Last reply
                                  0
                                  • R R Giskard Reventlov

                                    I didn't say it was. What is your problem? You're not right: it isn't the only answer and I already said that custom wasn't either.

                                    Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                                    N Offline
                                    N Offline
                                    Not Active
                                    wrote on last edited by
                                    #17

                                    What the hell is your problem? You start off with "That does not suit every occasion - it is wrong to tell people that." That was a very offensive attitude to begin an open discussion with. Followed up with "Your're not right" shows a lack of respect for other viewpoints and the people who present them. There is no right or wrong, we have choices. I stand by my comments that in this case the OP should not be creating a mechanism that already exists. You can disagree, but you don't have to be disagreable.


                                    I know the language. I've read a book. - _Madmatt

                                    R O 2 Replies Last reply
                                    0
                                    • N Not Active

                                      What the hell is your problem? You start off with "That does not suit every occasion - it is wrong to tell people that." That was a very offensive attitude to begin an open discussion with. Followed up with "Your're not right" shows a lack of respect for other viewpoints and the people who present them. There is no right or wrong, we have choices. I stand by my comments that in this case the OP should not be creating a mechanism that already exists. You can disagree, but you don't have to be disagreable.


                                      I know the language. I've read a book. - _Madmatt

                                      R Offline
                                      R Offline
                                      R Giskard Reventlov
                                      wrote on last edited by
                                      #18

                                      Mark Nischalke wrote:

                                      That does not suit every occasion - it is wrong to tell people that."

                                      You found that offensive? Grow up: I thought that fairly polite. Take it howver you want, I suppose.

                                      Mark Nischalke wrote:

                                      I stand by my comments that in this case the OP should not be creating a mechanism that already exists

                                      Rubbish. There is always more than one way to skin a cat and just because MS give you something for free doesn't mean you have to use it.

                                      Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                                      1 Reply Last reply
                                      0
                                      • A awedaonline

                                        Thanks a lot. but I don't seem to understand what and how to imlement that attribute you are saying. Do you mean a property?

                                        R Offline
                                        R Offline
                                        R Giskard Reventlov
                                        wrote on last edited by
                                        #19

                                        I think you need to start figuring some of this out for yourself: there is a lot of information about attributes all over the web and especially within Code Project..

                                        Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

                                        1 Reply Last reply
                                        0
                                        • A awedaonline

                                          Thanks a lot. but I don't seem to understand what and how to imlement that attribute you are saying. Do you mean a property?

                                          N Offline
                                          N Offline
                                          Not Active
                                          wrote on last edited by
                                          #20

                                          As I've been trying to point out if you use the built-in mechanism all of this is handled for you, plus other benefits.


                                          I know the language. I've read a book. - _Madmatt

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups