Search code examples
asp.net-core-3.1.net-core-3.1

How to remove 'Server' header from .net core 3.1 api response?


How to configure .net core 3.1 application to prevent 'Server' in the response header


Solution

  • Add a web.config file to the web project with this content (you may have additional content you merge in to your web.config file):

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <security>
          <requestFiltering removeServerHeader="true" />
        </security>
      </system.webServer>
    </configuration>