After upgrading an application from ASP.NET MVC 1 to ASP.NET MVC 2 RC cache substitution has stopped working.
This is my action:
[OutputCache(Duration = 30, VaryByParam = "none")]
public ActionResult CacheTest1()
{
return View("CacheTest");
}
This is the Substitute 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 view:
<%@ 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 substitution does not work, it just shows the time when the page was initially rendered. That was working in ASP.NET MVC 1.0!!
Any ideas?
Thanks