Question
How do you remove "Server:Kestrel" from the response header in a .Net Core 3 application?
In earlier versions you could do something like the below which is mentioned in this Stack Overflow answer.
Net Core 1
var host = new WebHostBuilder()
.UseKestrel(c => c.AddServerHeader = false)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
Net Core 2
WebHost.CreateDefaultBuilder(args)
.UseKestrel(c => c.AddServerHeader = false)
.UseStartup<Startup>()
.Build();
Net Core 3 (UseKestrel() is not found, and does not work, so the below is not possible.)
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseKestrel(c => c.AddServerHeader = false)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});