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 asp.net core only has a ResponseCacheAttribute
(which is an MVC attribute) and no parallel attribute for WebApi.
My questions are:
a. due to the shift from ApiController
and MvcController
to a united Controller
, 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.