Question: I need to know which domain send request to my C# action(MVC),
I get the request and return JS code,

For example:
Someone put this code in is site(<http://www.ClientExampleSite.com/>) :

```
<script src="http://www.MyExampleSite.com/GetDomin /GetDomin" type="text/javascript"></script>

```

I need to return this code:

```
Var Domin = 'www.ClientExampleSite.com';

```

The problem is that UrlReferrer don't work in this situation.

Thanks 

***edit:***
In the end what I want to do is to block requests from unknow domains.

Answer: 
You can use, 

var domainName = System.Web.HttpContext.Current.Request.Url.Authority;

Or you can try,

```
var theProvider = (IServiceProvider)HttpContext;
var theWorker = (HttpWorkerRequest)theProvider.GetService(typeof(HttpWorkerRequest));
string theReferer = theWorker.GetKnownRequestHeader(HttpWorkerRequest.HeaderReferer);  

```

**Updates:**
Based from your comment you can fetch client domain name from IP adress below code

```
        var clientIP = (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]==null) ? System.Web.HttpContext.Current.Request.UserHostAddress:
                           System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        IPAddress addr = IPAddress.Parse(clientIP);
        IPHostEntry entry = Dns.GetHostEntry(addr);
        var clientDomainName = entry.HostName;

```
You can try this:

```
Uri myUri = new Uri("http://www.ClientExampleSite.com/");   
string domain = myUri.Host;

```

Refer [Uri.Host Property](https://msdn.microsoft.com/en-us/library/system.uri.host.aspx) 

> 
> Gets the host component of this instance.
> 
> 
> 

or you can try this:

```
var domain =   HttpContext.Current.Request.Url.Host;

```

To get the client domain name

```
string clientDomain = string.Empty;
clientDomain = context.Request.UrlReferrer.Host;

```