开发者

get underlying response stream from WebOperationContext

How do I get access to the un开发者_如何学编程derlying response stream from a WebOperationContext?


Change the return type of the method to Stream.

The code I use for returning an html/text stream is:

  public Stream GetHTML()
  {

      MemoryStream stream = new MemoryStream();
      StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
      writer.Write("HTML STRING");

      conn.Close();

      writer.Flush();
      stream.Position = 0;

      WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";

      return stream;
   }      

Obviously you'll have a different content type, and I don't think you'll have to use UTF8 encoding.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜