开发者

ASP.NET MVC View and Controller Output Caching

What is the difference between using output cache

in view:

    <%@ Page Language="C#"
    Inherits="System.Web.Mvc.ViewPage<M开发者_高级运维ahmure.WebUI.ViewModels.NewsletterVM>" %>
    <%@ OutputCache Duration="120" VaryByParam="none" %>

and in controller:

    [OutputCache(Duration = 120, VaryByParam = "none")]
    public ActionResult Index()
    {


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜