Previous page url

Discussion in 'ASP .Net Web Controls' started by Morris Neuman, Aug 30, 2009.

  1. Hi,
    How do I create a previous page links on a page that when clicked would
    return to the page that the user came from. This could be a different page
    based on the user's selection.

    For example, the flow could be:
    1) Page A to Page B to Page C
    2) Page A to Page C

    If the user is on Page C and clicks previous button then if they came to
    page c based on scenario 1 they would return to page B; if scenario 2 then
    return to page A.

    Is there a way to save the url of the page that the user came from?

    Thanks as always for your help.
     
    Morris Neuman, Aug 30, 2009
    #1
    1. Advertisements

  2. Morris Neuman

    Ed Murphy Guest

    The usual solution is as follows:

    <a href="#" onclick="history.go(-1)">Back</a>
     
    Ed Murphy, Aug 30, 2009
    #2
    1. Advertisements

  3. Hello Morris,

    If you want to get the previous url on server-side, you can get the
    previous url by using Request.ServerVariables["HTTP_REFERER"].

    But you can not always get the information about it.

    1. Some proxys can not send the the information about HTTP url to you.
    2. Some Clients can prevent from sending IP and URL by "header_access deny".
    In above scenarios, HTTP_REFERER, HTTP_VIA and HTTP_X_FORWARDED_FOR are
    null.

    So we can't ensure to get the information about HTTP_REFERER, HTTP_VIA and
    HTTP_X_FORWARDED_FOR.

    If you just want to create a button/link to allow the user go back to the
    previous page, you can use script history.go(-1) like emurphy said.

    Sincerely,

    Vince Xu

    Microsoft Online Support


    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================

    --------------------
    | Thread-Topic: Previous page url
    | thread-index: Acopk0/kYPv8gnEmTxeLVonQ3wRepw==
    | X-WBNR-Posting-Host: 71.167.160.58
    | From: =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?= <>
    | Subject: Previous page url
    | Date: Sun, 30 Aug 2009 10:00:01 -0700
    | Lines: 20
    | Message-ID: <>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4325
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    | Path: TK2MSFTNGHUB02.phx.gbl
    | Xref: TK2MSFTNGHUB02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webcontrols:4883
    | NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    |
    | Hi,
    | How do I create a previous page links on a page that when clicked would
    | return to the page that the user came from. This could be a different
    page
    | based on the user's selection.
    |
    | For example, the flow could be:
    | 1) Page A to Page B to Page C
    | 2) Page A to Page C
    |
    | If the user is on Page C and clicks previous button then if they came to
    | page c based on scenario 1 they would return to page B; if scenario 2
    then
    | return to page A.
    |
    | Is there a way to save the url of the page that the user came from?
    |
    | Thanks as always for your help.
    |
    | --
    |
    | Morris
    |
     
    Vince Xu [MSFT], Aug 31, 2009
    #3
  4. Thanks Ed and Vince.

    Used the history.go(-1) which works well.
    --
    Thanks
    Morris


     
    Morris Neuman, Aug 31, 2009
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.