1

What is the difference between using output cache

in view:

    <%@ Page Language="C#"
    Inherits="System.Web.Mvc.ViewPage<Mahmure.WebUI.ViewModels.NewsletterVM>" %>
    <%@ OutputCache Duration="120" VaryByParam="none" %>

and in controller:

    [OutputCache(Duration = 120, VaryByParam = "none")]
    public ActionResult Index()
    {
1
  • The difference is View-level caching vs Action-level caching. The former isn't currently cleanly supported in ASP.NET MVC. Commented Oct 25, 2010 at 18:17

1 Answer 1

4

In ASP.NET MVC model it is more correct to use the attribute on your controller action because URLs are no longer dictated by views (as it is in classic WebForms) but from routing and it is the controller action that first gets the request and decides whether to fetch it from the cache or not.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.