I'm currently running my application under either Kestrel (locally) or IIS InProcess (production).
return WebHost.CreateDefaultBuilder(args)
.ConfigureKestrel(options => options.AddServerHeader = false)
.UseIIS()
.UseStartup<Startup>();
I'd like to be able to get the hosting server name at runtime in a controller so I can achieve the following:
if (hostingServer == "kestrel")
{
DoSomething();
}
else
{
DoSomethingElse();
}
In this specific case it's to get around the fact that non-ascii characters are not supported in response headers with Kestrel. Ideally I would remove the non-ascii header but currently it's required for legacy interoperability.
Any help would be massively appreciated.