I like the simplicity and usability that OutputCache offers in MVC Controllers. I could see a usage for such caching functionality in other "heavy" functions that are not controller actions, but since it is in the System.Web.Mvc namespace I was curios to know weather or not it is intended for that kind of use?

有帮助吗?

解决方案

It's not intended nor will it work for caching the output of a method. Looking at the source code of the OutputCache attribute, it looks like it's very tightly coupled to the HttpContext and actually writes out to the response. So it's really meant for caching the HTML output of your actions.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top