Share via


Is there a standard way in .net core to avoid Server: Kestrel header in asp.net response?

Question

Friday, October 5, 2018 7:45 AM

Hello all!

Is there a standard way in .net core to remove Server: Kestrel header from asp.net core 2 http response in my webapp?

Thank you.

All replies (1)

Friday, October 5, 2018 9:07 AM âś…Answered

Hi Alex9 ,

You could remove the Server header by setting the AddServerHeader property to false on KestrelServerOptions, this can be done in the Program.cs.

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                   .UseKestrel(options => options.AddServerHeader = false)
                .UseStartup<Startup>();

Best Regards

Sherry