dcsimg
Results 1 to 7 of 7
  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Any way to know from where my page was called?

    I have a asp.net page I am working with and I would like to be able to tell from where the page was loaded if possible. I thought maybe sender in the page load event would give me that info but it just gives me the current page rather than the page that called it.

    In this case I have a page that can normally be called one of three ways.
    1: The user completes a Paypal transaction
    2: The user chooses to pay later
    3: The user enters the address [and any other info required] in the address bar

    In the case of 3 the page would redirect them most of the time due to certain variables not being set but there is a point where they could enter the direct address and trigger the page.

    The main thing I need to be able to know is was the page called from PayPal or was it called from another method.

    I do not do much ASP coding and this is my first time working with Paypal so I am hoping there is a simple solution that i am just not seeing.

    Any help would be appreciated.

  2. #2
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    773

    Re: Any way to know from where my page was called?

    THe only way I can think of is to check HttpContext.Current.Request.UrlReferrer and see what is in there, that should tell you where the request has come from.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Re: Any way to know from where my page was called?

    I thought I had found what I needed. I added
    Code:
    MyString=Request.UrlReferrer.ToString
    To the Page_Init() routine and when I called the page from another page on my local server it did provide the info I was looking for.

    Unfortunately when I added the code to the live page and it returned from PayPal the value was null and caused an error. I added code to trap the error and handle the null but then it is just an empty string so... looks like I need to do something different.

    Is this
    Code:
    HttpContext.Current.Request.UrlReferrer
    The same as this in the context of a web page?
    Code:
    Request.UrlReferrer
    When I call the page in question from a test page on my local server I get
    http://localhost:49211/WebSite/testpage2.aspx
    in the MyString var

    When it loads as the return target from PayPal I get null ?
    Last edited by DataMiser; May 8th, 2018 at 11:04 AM.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Re: Any way to know from where my page was called?

    Well I thought I was getting a null but what I am getting upon return from paypal is.

    Object reference not set to an instance of an object.
    Now using the code below
    Code:
     Dim mystring As String
            Try
                mystring = Request.UrlReferrer.ToString & ""
            Catch ex As Exception
                mystring = ex.Message
            End Try
    When called from my test page I do get the correct URL.

    Anything else I should try?

  5. #5
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    773

    Re: Any way to know from where my page was called?

    Is your site using https or just plain http? I am fairly sure most browsers tend to strip the refer when moving from https to http - might be worth setting up https and seeing if that fixes the issue. Then again if you are dealing with payments in any form it is probably sensible to have https in place anyway.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Re: Any way to know from where my page was called?

    I had not thought of that.
    I am doing this site for a friend, a small non profit type thing and as of now they have not gotten a security certificate so yes it is going from https at paypal to http for the little web site.

    I'll check with them and see if they can get whatever is needed to use https

    Thanks.

  7. #7
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    773

    Re: Any way to know from where my page was called?

    https://letsencrypt.org/ is worth considering, valid ssl certs for free. Depending on the hosting environment it might take a bit of setting up but a bit of effort is a lot cheaper than the cost of a SSL cert from most places.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.