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

相关文章
|
14天前
|
区块链
max code size exceeded
max code size exceeded
25 6
|
9月前
|
Java 应用服务中间件
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
80 0
|
11月前
|
Java Spring
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
209 0
|
编解码 算法 测试技术
[译]Page Multiplexing and Ordering in a Physical Ogg Stream
Ogg容器格式的设计和排列受几个高级设计决策支配,这些决策构成了特定的低级设计决策的依据。
57 0
|
Java 应用服务中间件
The field file exceeds its maximum permitted size of 1048576 bytes.
The field file exceeds its maximum permitted size of 1048576 bytes.
|
前端开发 Java 关系型数据库
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
1069 0
|
关系型数据库 测试技术
ERROR 2020 (HY000): Got packet bigger than 'max_allowed_packet' bytes
今天在测试环境发生了貌似怪异的报错,表结构如下: CREATE TABLE `test` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `step` bigint(20) NOT NULL COMMENT 'step', `da.
2682 0
|
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.
4499 0