After updating the application from ASP.NET MVC 1 to ASP.NET MVC 2, reloading the RC cache stopped working.
This is my action:
[OutputCache(Duration = 30, VaryByParam = "none")] public ActionResult CacheTest1() { return View("CacheTest"); }
These are replacement extensions:
public static object Substitute(this HtmlHelper html, MvcCacheCallback cb) { html.ViewContext.HttpContext.Response.WriteSubstitution( c => cb(new HttpContextWrapper(c))); return null; }
And this is my opinion:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>CacheTest</title> </head> <body> <div> Date: <%=DateTime.Now.ToString() %> Substitute: <%=Html.Substitute(c => DateTime.Now.ToString()) %> Response.WriteSubstitution: <% Response.WriteSubstitution(c => DateTime.Now.ToString()); %> </div> </body> </html>
The page is cached for a minute, and the substitution does not work, it just shows the time when the page was originally displayed. This worked in ASP.NET MVC 1.0!
Any ideas?
thanks
source share