1myb
1myb

Reputation: 3596

How to know the user is from site A

I have certain API for site B, but i need to let site B know when is the right time to execute them. The right time is when user come from site A. How can i make sure the visitor is from site A? the programming language of site B maybe C# aspx, or php.

update I need to make the entire site B know about user from site A. or else new page or redirection would cause the script not working.

Upvotes: 0

Views: 130

Answers (3)

शेखर
शेखर

Reputation: 17614

You can use this function in asp.net to get the referral URL

    public static string GetReferalUrl()
    {
        var lStrRefUrl = "";
        if (HttpContext.Current.Request.UrlReferrer != null)
            lStrRefUrl = HttpContext.Current.Request.UrlReferrer.Host;
        return lStrRefUrl;
    }

You can every information form HttpContext.Current.Request about the request.

Note that the user may hide about the server information. It can also hide weather it is IIS or other web server. It's just a configuration which you need to remove form the server or from the individual site.

Here is a good link about the request headers.
How to dump ASP.NET Request headers to string

Upvotes: 1

Sorter
Sorter

Reputation: 10220

As the request contains the header referer. In java, you can use this.

String referrer = request.getHeader("referer");

Check the network panel in chrome.Click on the request and See under the headers tab. You will see the referer as google, if you visit a page from google.

Upvotes: 2

user2116306
user2116306

Reputation:

You need to look at the HTTP Referer Header:

$_SERVER['HTTP_REFERER']

See PHP Documentation for more HTTP Headers

Upvotes: 3

Related Questions