5

All the examples for donut caching I've seen are just like this :

 <%= Html.Substitute( c => DateTime.Now.ToString() )%>

Thats fine if I just want the date, but what other options are there?

I know there is a delegate 'MvcSubstitutionCallback' which has the following signature :

 public delegate string MvcSubstitutionCallback(HttpContextBase httpContext); 

but RenderAction and RenderPartial returns void so i cant just return them from the delegate method. How can I effectively use this callback for more complex situations.

I've looked at both of Phil Haacked's articles here and here, but neither seems to do exactly what I want.

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
  • Any update on this? Do you have a html helper that works now? – Robert Claypool Sep 11 '09 at 16:06
  • you wait four months and then two comments all at once. I'm interested in this too, will post back any findings. Guessing we'd need a new helper wrapping around html.ViewContext.HttpContext.Response.WriteSubstitution – dove Sep 11 '09 at 16:46
  • @robert once i added authentication to my pages that just opened up a can of worms and i ended up mostly turning off caching throughout my site. had to prioritize other things. i'll wait for a better official response – Simon_Weaver Sep 11 '09 at 18:30

1 Answers1

3

"Donut Caching" means using Response.WriteSubstitution method. If you look at MVC source you will see that System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial method is using Response.Output (HtmlHelper.cs, line 277 - last line in 'RenderPartialInternal' method) - so you need create your own html helpers for handling more complex situations.

eu-ge-ne
  • 28,023
  • 6
  • 71
  • 62