Bytes to be written to the stream exceed the Content-Length bytes size specified 解决方法
2014-10-14 17:09
696 查看
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);
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);
相关文章推荐
- (转)HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误
- HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误
- Git pull error:Your local changes to the following files would be overwritten by merge解决方法
- Entity Framework出现System.Data.MetadataException: Unable to load the specified metadata resource的解决方法
- IIS出现The specified module could not be found解决方法
- mysql建库时提示Specified key was too long max key length is 1000 bytes的问题的解决方法
- Connector/Net 连接 MySQL远程服务器出现 "Unable to connect to any of the specified MySQL hosts" 解决方法
- CI框架中Unable to locate the model you have specified:*_model解决方法
- IIS错误解决方法:The specified module could not be found、访问 IIS 元数据库失败
- java.sql.SQLException: The value supplied cannot be converted to DECIMAL 解决方法
- IIS出现The specified module could not be found解决方法
- IIS出现The specified module could not be found错误解决方法!
- 关于The target "GetCopyToOutputDirectoryContentProjectItems" does not exist in the project.的解决方法
- All bytes must be within the maximum size specified by CreateFileMapping
- IIS出现The specified module could not be found解决方法(zhuan)
- IIS出现The specified module could not be found的解决方法
- vs2005下出现“Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive”的解决方法
- IIS出现The specified module could not be found的解决方法
- 解决IIS出现The specified module could not be found的方法
- ISAPI程序出现“The specified module could not be found”问题解决方法