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); 

相关文章:

  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
  • 2021-04-01
  • 2022-12-23
  • 2021-07-05
猜你喜欢
  • 2022-02-08
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-10-04
  • 2021-08-28
相关资源
相似解决方案