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

简介:
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,如需转载请自行联系原作者

相关文章
|
3月前
|
JSON PHP 数据格式
PHP Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)
PHP Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)
67 2
|
5月前
|
区块链
max code size exceeded
max code size exceeded
62 6
|
Java 应用服务中间件
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
161 0
|
Java Spring
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
686 0
|
Java 应用服务中间件
The field file exceeds its maximum permitted size of 1048576 bytes.
The field file exceeds its maximum permitted size of 1048576 bytes.
|
程序员 算法框架/工具 Caffe
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
728 0
|
前端开发 Java 关系型数据库
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
1127 0
|
小程序
小程序Error: 系统错误,错误码:80200,main package source size 2590KB exceed max limit 2MB
小程序Error: 系统错误,错误码:80200,main package source size 2590KB exceed max limit 2MB
1484 0
小程序Error: 系统错误,错误码:80200,main package source size 2590KB exceed max limit 2MB
|
Web App开发 Java 关系型数据库
Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unex
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} span.s1 {font: 12.
4637 0