Get request origin in C# api controller

What you're looking for is probably the origin-header. All modern browsers send it along if you're doing a cross domain request.

In an ApiController you fetch it like so:

if (Request.Headers.Contains("Origin"))
{
    var values = Request.Headers.GetValues("Origin");
    // Do stuff with the values... probably .FirstOrDefault()
}

You can grab it from the API methods via current HTTP request headers collection:

  IEnumerable<string> originValues;
  Request.Headers.TryGetValue("Origin", out originValues)