本文介绍了如何在C#中将字符串写入response.outputstream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在ASP.net页中使用response.OutputStream,
此页面将返回字符串值,
我想将此字符串值放入response.OutputStream

请怎么做

Thanks

Hi,

I am using response.OutputStream in ASP.net page,
this page will return string value,
and i want put this string value in response.OutputStream

How to do that please

thanks

推荐答案

using (StreamReader reader = new StreamReader(yourStream))
{
  string myString = reader.ReadToEnd();
}



已更新-答案已根据您在解决方案1中发布的评论进行了更新.



Updated - Answer Updated based on your comment posted in Solution-1.

string s = "YourString";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);

Response.OutputStream.Write(bytes, 0, bytes.Length);



myResponse.OutputStream.ToString()


这篇关于如何在C#中将字符串写入response.outputstream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 03:37