How do I get the current subdomain within .Net Core middleware?
I have managed to work out my own answer in the meantime...comments appreciated.
private static string GetSubDomain(HttpContext httpContext)
{
var subDomain = string.Empty;
var host = httpContext.Request.Host.Host;
if (!string.IsNullOrWhiteSpace(host))
{
subDomain = host.Split('.')[0];
}
return subDomain.Trim().ToLower();
}