Reputation: 524
I am new to ASP.NET MVC framework, I would like to achieve the below requirement. Kindly let me know if it is possible.
I have a Master Data in the application and I get the MasterData on one controller action.
[HttpPost]
[OutputCache(Duration=60*60, VaryByParam="", CacheProfile="Books")]
public ActionResult GetBooks()
{
}
I would like to use the Master Data Cached as part of the previous action method.
[HttpPost]
public ActionResult EditBooks()
{
return View("_EditBook");
}
How can I access the Cached Data in asp.Net mvc?
Upvotes: 0
Views: 493
Reputation: 1038830
The OutputCache is used to cache the HTML (or whatever result it returned) that was rendered by a controller action so that the next time this action is called, its body is not executed, but the cached data directly returned. You cannot access the cached data that is stored in the output cache. That's not the purpose of output cache.
The OutputCache attribute can also be applied to child actions in order to cache onmly fragments of the web page.
If on the other hand you want to cache some .NET objects (such as for example a collection of some type that was returned in a controller action) you could use the MemoryCache.
Upvotes: 1