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. To ensure that users come from page1 before going to page2

To ensure that users come from page1 before going to page2

Scheduled Pinned Locked Moved ASP.NET
question
7 Posts 3 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.
  • D Offline
    D Offline
    Desmond Lim
    wrote on last edited by
    #1

    Hi guys, I'm wondering if it there is a better way of doing this, I have 2 webpages, page1 and page2. I want to ensure that users would go to page1 before going to page2 (a button on page1, redirects it to page2), so that if the user types in the URL of page2, it will redirect to page1 first. I am currently using the Request.UrlReferrer.ToString() to get the the previous webpage and comparing it. If it is from page1 then page2 will open if not it will redirect to page1 (the code is below). I'm just wondering if there is a better way of doing this? Thanks.

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    if (Request.UrlReferrer.ToString() != "page1")
    {
    Response.Redirect("page1");
    }
    }
    }

    C 1 Reply Last reply
    0
    • D Desmond Lim

      Hi guys, I'm wondering if it there is a better way of doing this, I have 2 webpages, page1 and page2. I want to ensure that users would go to page1 before going to page2 (a button on page1, redirects it to page2), so that if the user types in the URL of page2, it will redirect to page1 first. I am currently using the Request.UrlReferrer.ToString() to get the the previous webpage and comparing it. If it is from page1 then page2 will open if not it will redirect to page1 (the code is below). I'm just wondering if there is a better way of doing this? Thanks.

      protected void Page_Load(object sender, EventArgs e)
      {
      if (!IsPostBack)
      {
      if (Request.UrlReferrer.ToString() != "page1")
      {
      Response.Redirect("page1");
      }
      }
      }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I would put pages one and two on the same URL, as controls. Then I'd use viewstate to store if the user had viewed page one before allowing page 2 to show, and set something on the URL to show page 2.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      D A 2 Replies Last reply
      0
      • C Christian Graus

        I would put pages one and two on the same URL, as controls. Then I'd use viewstate to store if the user had viewed page one before allowing page 2 to show, and set something on the URL to show page 2.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        D Offline
        D Offline
        Desmond Lim
        wrote on last edited by
        #3

        Can that be easily done? I have a lot of controls in page1 and page2.

        C 1 Reply Last reply
        0
        • C Christian Graus

          I would put pages one and two on the same URL, as controls. Then I'd use viewstate to store if the user had viewed page one before allowing page 2 to show, and set something on the URL to show page 2.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          A Offline
          A Offline
          AprNgp
          wrote on last edited by
          #4

          Christian Graus wrote:

          I would put pages one and two on the same URL, as controls

          I think wizard control has similar property ...

          Apurv “Never trust a computer you can’t throw out a window.” (Steve Wozniak) “There are only two industries that refer to their customers as ‘users’.” (Edward Tufte)

          C 1 Reply Last reply
          0
          • A AprNgp

            Christian Graus wrote:

            I would put pages one and two on the same URL, as controls

            I think wizard control has similar property ...

            Apurv “Never trust a computer you can’t throw out a window.” (Steve Wozniak) “There are only two industries that refer to their customers as ‘users’.” (Edward Tufte)

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Yes, but the more you use the ridiculous built in stuff, the less control you have over what's going on.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            A 1 Reply Last reply
            0
            • D Desmond Lim

              Can that be easily done? I have a lot of controls in page1 and page2.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Yes, just move all the code from your aspx and aspx.cs to ascx and ascx.cs files. Then put those two controls on the one page.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              • C Christian Graus

                Yes, but the more you use the ridiculous built in stuff, the less control you have over what's going on.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                A Offline
                A Offline
                AprNgp
                wrote on last edited by
                #7

                u r rite ...

                Apurv “Never trust a computer you can’t throw out a window.” (Steve Wozniak) “There are only two industries that refer to their customers as ‘users’.” (Edward Tufte)

                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