Cache the Output of the Action Method in ASP.NET MVC

Updated on     Kisan Patel

To cache the output of the action method, we can use OutputCache attribute in the action method of the controller.

[OutputCache(Duration=30)]
public string Index()
{
     return DateTime.Now.ToString();
}

The output of this action method will be cached for 30 seconds from the current date.


ASP.NET MVC

Leave a Reply