try
{
System.IO.Stream s = Request.InputStream;
int count = 0;
byte[] buffer = new byte[1024];
StringBuilder builder = new StringBuilder();
while ((count = s.Read(buffer, 0, 1024)) > 0)
{
builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
}
string post = builder.ToString();
}
catch (Exception ex)
{
throw ex;
}
{
System.IO.Stream s = Request.InputStream;
int count = 0;
byte[] buffer = new byte[1024];
StringBuilder builder = new StringBuilder();
while ((count = s.Read(buffer, 0, 1024)) > 0)
{
builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
}
string post = builder.ToString();
}
catch (Exception ex)
{
throw ex;
}
本文详细解释了如何通过使用.NET Framework的System.IO.Streams来读取HTTP请求流,并将其转换为UTF-8编码的字符串。通过实例代码演示了如何实现这一过程,包括错误处理机制。

被折叠的 条评论
为什么被折叠?



