urlasp.net-web-apibase-urlasp.net-web-api2

How to get base URL in Web API controller?


I know that I can use Url.Link() to get URL of a specific route, but how can I get Web API base URL in Web API controller?


Solution

  • You could use VirtualPathRoot property from HttpRequestContext (request.GetRequestContext().VirtualPathRoot)