I have a filter in place to capture HTML output, convert it to a string, perform some operations to modify the string, and return a ContentResult with a new string. Sorry, I'm ending an empty line.
private class UpdateFilter : ActionFilterAttribute { private Stream stream; public override void OnActionExecuting(ActionExecutingContext filterContext) { stream = filterContext.HttpContext.Response.Filter; stream = new MemoryStream(); filterContext.HttpContext.Response.Filter = stream; } public override void OnResultExecuted(ResultExecutedContext filterContext) { StreamReader responsereader = new StreamReader(filterContext.HttpContext.Response.Filter);
I bound this StreamReader (stream) .ReadToEnd () returns an empty string, but I can not understand why.
Any ideas how to fix this?
EDIT : I changed OnActionExecuted to OnResultExecuted, and now it is called after the View has been generated, but the stream is still empty!
yoozer8
source share