Headers are added in later versions of .NET Core 8 and 9 only for the Apps deployed in Windows.
Linux App:
Also referred this Doc and tried to remove the header using the Middleware class.
Thanks @Thomas Ardal for the explanation.
ASP.NET
Core will return theX-Powered-By
header. This happens when you host your website on IIS. you simply cannot remove the header in middleware, since this is out of hands forASP.NET
Core.web.config
to the rescue:
Output with Web.config
:
Web.config
file will be created in the application root directory.Also refer this blog for more details.