开发者

ViewContext.Writer() doesn't exist in ASP.NET MVC 1.0?

开发者 https://www.devze.com 2022-12-24 04:58 出处:网络
I have the following code in开发者_运维百科 an ASP.NET MVC 2 application. internal TextWriter _writer;

I have the following code in开发者_运维百科 an ASP.NET MVC 2 application.

internal TextWriter _writer;
// some stuff
_writer = _viewContext.Writer;
_writer.Write(_tag.ToString(TagRenderMode.EndTag));

I tried to move it to MVC 1 and now it doesn't build any more. I'm getting this error:

'System.Web.Mvc.ViewContext' does not contain a definition for 'Writer'

Can someone point out how I can resolve this?


I figured it out:

using (TextWriter textWriter = new StreamWriter(_viewContext.HttpContext.Response.OutputStream))
{
    textWriter.Write(_tag.ToString(TagRenderMode.EndTag));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消