public override void OnResultExecuted(ResultExecutedContext context) { if (_suppressResultFiltering) { return; } HttpResponseBase response = context.HttpContext.Response; CaptureFilter filter = (response.Filter as CaptureFilter); if (filter == null) { return; } response.Flush(); response.Filter = _filter; string content = filter.GetContents(response.ContentEncoding); response.Write(content); if (context.Exception == null) { UpdateCachedValue(_cacheKey, content); } }
/// <summary>Renders the action and returns a string.</summary> /// <param name="renderer">The delegate to render.</param> internal string Capture(Action renderer) { HttpResponseBase response = _context.Response; Stream originalFilter = null; CaptureFilter filter; string html = ""; if (renderer != null) { try { _context.Session.UpdateSessionId(); response.Flush(); originalFilter = response.Filter; filter = new CaptureFilter(response.Filter); response.Filter = filter; renderer(); response.Flush(); html = filter.GetContents(response.ContentEncoding); } finally { if (originalFilter != null) { response.Filter = originalFilter; } } } return(html); }
/// <summary>Renders the action and returns a string.</summary> /// <param name="renderer">The delegate to render.</param> internal string Capture(Action renderer) { HttpResponseBase response = _context.Response; Stream originalFilter = null; CaptureFilter filter; string html = ""; if (renderer != null) { try { _context.Session.UpdateSessionId(); response.Flush(); originalFilter = response.Filter; filter = new CaptureFilter(response.Filter); response.Filter = filter; renderer(); response.Flush(); html = filter.GetContents(response.ContentEncoding); } finally { if (originalFilter != null) response.Filter = originalFilter; } } return html; }