Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the referrer's web server name

Tags:

c#

.net

asp.net

I am placing a JS file to remote server(s). I d like to know where the request is coming from.

ie : i have a js on google.com and upon user click on the link that s produced by js, it triggers some c# code on my server, but i also have the same js on yahoo.com and i d like to be able to know where the request is coming from.

How to find this ?

like image 494
DarthVader Avatar asked Mar 10 '10 04:03

DarthVader


2 Answers

System.Environment.MachineName should contain the name of the server.

like image 100
robyaw Avatar answered Sep 21 '22 01:09

robyaw


In ASP.NET, the referring page is given by Request.UrlReferrer as a Uri object.

This is also available as Request.ServerVariables["HTTP_REFERER"] as a string.

like image 43
Lachlan Roche Avatar answered Sep 24 '22 01:09

Lachlan Roche