shirbr510 shirbr510 - 2 months ago 11
C# Question

is there any ResponseCacheAttribute for WebAPI Core?

I'm currently working with WebAPI 2 and considering to upgrade to ASP.Net Core.

as I've reached the

Http Caching
topic I've noticed that core only has a
(which is an MVC attribute) and no parallel attribute for WebApi.

My questions are:

a. due to the shift from
to a united
, will the MVC attribute work on WebApi actions?

b. if not, is there an implemented alternative for WebApi?


Answers to your questions:

a. There's no such thing as MVC and WebAPI anymore. As you noted, the products have been unified into just MVC. Actually, the team usually just refer to everything as just "ASP.NET Core", since it's mostly different middleware composed together anyway. This also means that there's no such thing as a "WebAPI action". It's all just MVC actions. Which again means that yes, ResponseCacheAttribute will work.

b. See above. BTW, there's also a response caching middleware being worked on for v1.1 of ASP.NET Core.