title: Is Cache Substitution working in ASP.NET MVC 2?
body: <p>After upgrading an application from ASP.NET MVC 1 to ASP.NET MVC 2 RC cache substitution has stopped working.</p>
  
  <p>This is my action:</p>
  
  <pre><code> [OutputCache(Duration = 30, VaryByParam = "none")]
   public ActionResult CacheTest1()
   {
        return View("CacheTest");
   }
  </code></pre>
  
  <p>This is the Substitute extensions:</p>
  
  <pre><code>public static object Substitute(this HtmlHelper html, MvcCacheCallback cb)
  {
      html.ViewContext.HttpContext.Response.WriteSubstitution(
          c =&gt; cb(new HttpContextWrapper(c)));
      return null;
  }
  </code></pre>
  
  <p>And this is my view:</p>
  
  <pre><code>&lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;CacheTest&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div&gt;
      Date: &lt;%=DateTime.Now.ToString() %&gt;
      Substitute: &lt;%=Html.Substitute(c =&gt; DateTime.Now.ToString()) %&gt;
      Response.WriteSubstitution: &lt;% Response.WriteSubstitution(c =&gt; DateTime.Now.ToString()); %&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>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!!</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>