Remove “Server” header from ASP.NET Core 2.1 application

前端 未结 4 1066
[愿得一人]
[愿得一人] 2021-02-07 00:23

Is it possible to remove the Server Response header in a ASP.NET Core 2.1 application (running on Server 2016 with IIS 10)?

I tried putting the followin

4条回答
  •  情深已故
    2021-02-07 00:40

    For Dotnet Core 3.1 UseKestrel is part of ConfigureWebHostDefaults as opposed to CreateDefaultBuilder in earlier versions.

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup()
                          .UseKestrel(options => options.AddServerHeader = false);
            });
    

提交回复
热议问题