Although @Html.RenderPartial
calls write and returns void
, it is still writing to a StringWriter
/StringBuilder
. Is there a way to render directly to the ResponseStream
?
Can this be done with a custom IViewEngine
that implements render like PdfView
to directly output to the ResponseStream
?
ADDITION
ViewResultBase.ExecuteResult
shows the ViewContext
being built with Response.Output
, but debugger shows ViewContext.Writer
as a StringWriter
Both of these approaches results in a StringWriter
return PartialView("view", Model)
// or
PartialView("view", Model).ExecuteResult(ControllerContext)
EDIT
It appears that System.Web.WebPages.WebPageBase
ExecutePageHeirarchy
pushes a temp StringWriter
onto the context stack, so I'm not sure if this can be bypassed
IN SUMMARY
RenderPartial, RenderAction do not directly output to the Response.Stream, none of Razor Views will
SOLUTION
It was the new WebPages/Razor rendering engine that wraps everything with a StringWriter
to a StringBuilder
. The solution was to change my page to use the WebFormViewEngine
which does not apply this wrapping.