0
Posted on 3:28 AM by Softminer and filed under

Problem with Resonse.Output in Razor

I have a helper class which writes directly in Response. I am using this helper class in my master page and it write in the position
where Helper class is called.

<% Html.MyHelper() %>

but in Razor

@{ Html.MyHelper() }

its writing the response on the begining of page.

A Razor view is rendered inside-out. Basically it writes content to temporary buffers which get written to the response stream when the top most layout page is reached.

private static void MyHelper(this HtmlHelper html)
{
HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.HttpContext.Response.Output);
}


to replace using
html.ViewContext.HttpContext.Response
with
html.ViewContext.write
0
Responses to ... Problem with Response.Output in Razor