When implementing an asynchronous controller in ASP.NET MVC, if I want to display the cache ActionResult, which method did I put the attribute OutputCacheon?
public class PortalController : AsyncController {
[OutputCache(Duration = 60 * 30 , VaryByParam = "city")]
public void NewsAsync(string city) {
AsyncManager.OutstandingOperations.Increment();
NewsService newsService = new NewsService();
newsService.GetHeadlinesCompleted += (sender, e) =>
{
AsyncManager.Parameters["headlines"] = e.Value;
AsyncManager.OutstandingOperations.Decrement();
};
newsService.GetHeadlinesAsync(city);
}
[OutputCache(Duration = 60 * 30 , VaryByParam = "city")]
public ActionResult NewsCompleted(string[] headlines) {
return View("News", new ViewStringModel
{
NewsHeadlines = headlines
});
}
}
At first I suggested that this would continue NewsCompletedbecause it is a method that returns ActionResult.
Then I realized what was NewsAsyncconnected with VaryByParam, so it probably makes sense to add an attribute to this method.
source
share