context.Response.ContentType = encode;
using (StreamWriter writer = new StreamWriter(context.Response.OutputStream, UTF8))
{
writer.Write(str);
}
using (StreamWriter writer = new StreamWriter(context.Response.OutputStream, UTF8))
{
writer.Write(str);
}
上面代码常会报错:
Bytes to be written to the stream exceed the Content-Length bytes size specified
解决方法:
添加: context.Response.ContentLength64 = string.IsNullOrWhiteSpace(str) ? 0 : UTF8.GetByteCount(str);
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/p/4024809.html,如需转载请自行联系原作者