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 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
    Rutvik Dave
    wrote on last edited by
    #21

    Step 1) When you redirect user to the Login page (i.e. Login.aspx) pass the current url in Query string. i.e.

    Response.Redirect("Login.aspx?PreviousPage=" + Request.AppRelativeCurrentExecutionFilePath.ToString());

    Step 2) In the Login Page, after you authenticate user, Redirect the user back to the page in the query string. i.e.

    if(Request.QueryString["PreviousPage"] != null)
    Response.Redirect(Request.QueryString["PreviousPage"].ToString());
    else
    Response.Redirect("Some where else, might be your products page etc...");

    B A 2 Replies Last reply
    0
    • R Rutvik Dave

      Step 1) When you redirect user to the Login page (i.e. Login.aspx) pass the current url in Query string. i.e.

      Response.Redirect("Login.aspx?PreviousPage=" + Request.AppRelativeCurrentExecutionFilePath.ToString());

      Step 2) In the Login Page, after you authenticate user, Redirect the user back to the page in the query string. i.e.

      if(Request.QueryString["PreviousPage"] != null)
      Response.Redirect(Request.QueryString["PreviousPage"].ToString());
      else
      Response.Redirect("Some where else, might be your products page etc...");

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #22

      the same approach I have used in my project and found simple way to implement this.

      Cheers!! Brij

      1 Reply 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.

        J Offline
        J Offline
        JimBob SquarePants
        wrote on last edited by
        #23

        Passing the page that performed the redirect to your login would be quite easy. Just use a querystring. e.g default.aspx

        //get the current page url
        String url = Page.Request.RawUrl;

        //redirect the page to your new one
        Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/login.aspx?pp={0}", url));

        login.aspx

        //get the url of the previous page.
        if(Request.RawUrl.Contains("?pp="))
        {
        string previousPage = Request.QueryString["pp"]);
        }

        Once you have your value you could use the login control LoggedIn event to redirect to you original page using the query string you have captured. I know it's a chore but I heartily recommend getting a book on Asp.Net. Most beginners books will have plenty of information about this. Good luck!

        JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

        A 1 Reply 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

          O Offline
          O Offline
          Oakman
          wrote on last edited by
          #24

          Mark Nischalke wrote:

          You can disagree, but you don't have to be disagreable.

          Good advice - take it.

          Jon "I don't think the human race will survive the next thousand years, unless we spread into space. There are too many accidents that can befall life on a single planet. But I'm an optimist. We will reach out to the stars." ~ Stephen Hawking, Soap Box 1.0: the first, the original, reborn troll-less

          1 Reply Last reply
          0
          • J JimBob SquarePants

            Passing the page that performed the redirect to your login would be quite easy. Just use a querystring. e.g default.aspx

            //get the current page url
            String url = Page.Request.RawUrl;

            //redirect the page to your new one
            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/login.aspx?pp={0}", url));

            login.aspx

            //get the url of the previous page.
            if(Request.RawUrl.Contains("?pp="))
            {
            string previousPage = Request.QueryString["pp"]);
            }

            Once you have your value you could use the login control LoggedIn event to redirect to you original page using the query string you have captured. I know it's a chore but I heartily recommend getting a book on Asp.Net. Most beginners books will have plenty of information about this. Good luck!

            JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

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

            Thanks. Your instruction was helpful.

            1 Reply Last reply
            0
            • R Rutvik Dave

              Step 1) When you redirect user to the Login page (i.e. Login.aspx) pass the current url in Query string. i.e.

              Response.Redirect("Login.aspx?PreviousPage=" + Request.AppRelativeCurrentExecutionFilePath.ToString());

              Step 2) In the Login Page, after you authenticate user, Redirect the user back to the page in the query string. i.e.

              if(Request.QueryString["PreviousPage"] != null)
              Response.Redirect(Request.QueryString["PreviousPage"].ToString());
              else
              Response.Redirect("Some where else, might be your products page etc...");

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

              Your opinion was helpful. Thanks..

              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