Glimpse/Glimpse — Issue #154: OutputCache substitution does not work a response filter
Author: EtherZa
Created: 2012-01-10 07:01:45+00:00
State: open

As per http://support.microsoft.com/kb/2014472, output cache substitution is not supported when using a response filter.

A possible solution is to use a control adapter to render the html form and then to add the scripts in a substitution block. It is not as clean as using a response filter and will not be a viable solution with MVC, but does resolve the issue in web forms.

Sample control adapter:

using System;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;

public class GlimpseFormAdapter : ControlAdapter
{
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Control.Page.Response.WriteSubstitution(InsertScripts);
}

private static string InsertScripts(HttpContext context)
{
const bool Enabled = true;
if (Enabled)
{
return string.Format("

Insert Glimpse scripts here! Generated: {0}

", DateTime.Now.ToString(CultureInfo.InvariantCulture));
}

return string.Empty;
}
}