Change the headers of static files in Asp.net Core

后端 未结 5 1664
误落风尘
误落风尘 2020-12-06 05:47

I am using package Microsoft.AspNet.StaticFiles and configuring it in Startup.cs as app.UseStaticFiles(). How can I change the headers

5条回答
  •  庸人自扰
    2020-12-06 06:29

    You have to write a middleware to do this, I've a sample that remove headers on my github https://github.com/aguacongas/chatle
    Look at the ChatLe.HttpUtility project, it's a bit tricky. you can take a look of this question as well:

    How to do remove some httpresponse headers on each response like Server and ETag?

    However this will not work under IIS, because IIS manage statics files itself. It will work only on stand-alone application like kestrel or firefly

提交回复
热议问题