OutputCache in Razor view engine .cshtml page

ram picture ram · Dec 11, 2010 · Viewed 11.9k times · Source

Using ASP.NET MVC web forms we can put output cache either in controller level or view level. How can we mention "outputcache" in .cshtml page?

I did not find it anywhere. Where can I get the syntax?

Answer

RPM1984 picture RPM1984 · Dec 11, 2010

What do you mean "ASP.NET MVC Web Forms"? If you're referring to the OutputCache attribute in the Page directive, that is ASP.NET Web Forms.

ASP.NET MVC has Output Caching on the controller action level:

    [OutputCache(Duration=10, VaryByParam="none")]
    public ActionResult Index()
    {
        return View();
    }

This is irrespective of the view engine (ASPX/Razor).