2
votes

In order to solve a caching issue in IE I decorated my controllers with [ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]

When looking at the response headers in the browser developer tools I noticed that some of my controller action responses had the expected Cache-Control:no-store,no-cache

But others didn't. This was driving me nuts and after doing some digging I found the explanation in the msdn documentationenter image description here https://docs.microsoft.com/en-us/aspnet/core/performance/caching/middleware

So I tried disabling CSRF protection in my form by using the asp-antiforgery="false" attribute and sure enough the no-store directive was added to my response header.

So my question is: Is there any way to achieve this without having to sacrifice security by disabling CSRF protection in my forms? It definitely doesn't feel right to have to disable that just to prevent IE from caching my pages.

Thanks in advance for any help/advice that you can give me!

1

1 Answers

2
votes

So I opened an issue in the ASP.NET Core github's repo and the microsoft team confirmed that this is a bug that they are planning to address in version 2.0

https://github.com/aspnet/Mvc/issues/6432

They pointed me to a workaround which is not terribly appealing but given that we have no other choice I will post it here in case anyone is interested.

https://github.com/aspnet/Antiforgery/issues/116

Screenshots of the proposed workaround from github:

enter image description hereenter image description here