Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on some asp.net website with paypal payment gateway. I want when transaction is successfully completed then user will see a success page. But success page is only open when user come from paypal website.
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UrlReferrer.OriginalString.Contains("https://www.paypal.com/"))
        {
            if ((Request.QueryString["id"] == null || null == Request.QueryString["id"] || Request.QueryString["id"] == ""))
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                //code for execution
            }
        }
        else
        {
            Response.Redirect("Default.aspx");
        }
    }
Posted
Updated 25-Feb-15 10:13am
v2

1 solution

This is called "referred", can be sent to you in HTTP request coming from another page. Here is how: https://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx[^].

—SA
 
Share this answer
 
Comments
Raj Negi 26-Feb-15 2:28am    
can you please correct my solution.
Sergey Alexandrovich Kryukov 26-Feb-15 8:47am    
Looks fine from the first glance. I don't know the other detail your expect, such as query string parameters. What's the problem? It's easy to debug. Also, I would use not Contains but String.StartsWith. Even better, I would use parsed URI components (authority, host, etc.) to identify PayPal.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900