public override void Render(HttpContextBase httpContext, Bistro.Controllers.IContext requestContext) { if (httpContext.Session != null) foreach (object key in httpContext.Session.Keys) { if (requestContext.Contains(key)) throw new ApplicationException(String.Format("{0} is present on both the Session and the Request.", key)); requestContext.Add(key.ToString(), httpContext.Session[key.ToString()]); } try { TextReader reader = manager.RenderTemplate(requestContext.Response.RenderTarget, (IDictionary<string, object>)requestContext); char[] buffer = new char[4096]; int count = 0; while ((count = reader.ReadBlock(buffer, 0, 4096)) > 0) httpContext.Response.Write(buffer, 0, count); } catch (Exception ex) { httpContext.Response.StatusCode = 500; httpContext.Response.Write(RenderException(requestContext.Response.RenderTarget, ex, true)); } }