0

I'm on project using asp.net mvc2.

In master page I have some lines of code line this

<% Html.RenderPartialView("Header", Model.HeaderData) %>
...
<% Html.RenderPartialView("LeftMenu", Model.MenuData) %>
...
<% Html.RenderPartialView("Footer") %>

How could I apply caching to RenderPartialView

Thanks

noname.cs
  • 1,938
  • 4
  • 16
  • 25
  • if my partialview is an aspx insteal of ascx, I could use directive <%@ Page....> and <%@ OutputCache ...>, ex: header.aspx, leftmenu.aspx... but now I wonder have any wrong with that way, and how about performance when I use viewpage replace for viewcontrol. Why dont we add directive @OutputCahe to ViewControl ? – noname.cs Mar 11 '10 at 12:54

1 Answers1

0

You can not easily - the main problem is that at that at that point the caching thing is already done. it is executing the page construction.

Check http://www.klopfenstein.net/lorenz.aspx/output-donut-caching-attribute-asp-net-mvc-partial-requests for some stuff in this direction (including a nice discussion how caching workd under the hood).

TomTom
  • 61,059
  • 10
  • 88
  • 148