且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Bytes to be written to the stream exceed the Content-Length bytes size specified 解决方法

更新时间:2022-09-12 11:20:22

context.Response.ContentType = encode;
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,如需转载请自行联系原作者