Skip to content

Instantly share code, notes, and snippets.

@LGM-AdrianHum
Last active May 28, 2022 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LGM-AdrianHum/c3c8a37b657d6a0c00642ade7a8d6500 to your computer and use it in GitHub Desktop.
Save LGM-AdrianHum/c3c8a37b657d6a0c00642ade7a8d6500 to your computer and use it in GitHub Desktop.
Get the base URL of a web api or MVC page.
public string GetBaseUrl()
{
var appUrl = HttpRuntime.AppDomainAppVirtualPath;
return $"{Request?.Url.Scheme}://{Request?.Url.Authority}/{appUrl.TrimStart('/')}";
}
@LGM-AdrianHum
Copy link
Author

Used in the API documentation pages of ID4ME Search 2 website to provide live examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment