如何检查用户来自特定网址 [英] How to check user is coming from specific url

查看:71
本文介绍了如何检查用户来自特定网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用paypal支付网关在一些asp.net网站上工作。我想在事务成功完成后,用户将看到一个成功页面。但成功页面仅在用户来自paypal网站时才会打开。

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.

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");
        }
    }

推荐答案

这叫做推荐,可以在HTTP请求中发送给你从另一页。方法如下: https://msdn.microsoft.com/en-us/ library / system.web.httprequest.urlreferrer.aspx [ ^ ]。



-SA
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


这篇关于如何检查用户来自特定网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆