InvalidOperationException: Response Content-Length mismatch

Posted cnkker

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了InvalidOperationException: Response Content-Length mismatch相关的知识,希望对你有一定的参考价值。

 

FileStreamResult 抛出异常:

 

InvalidOperationException: Response Content-Length mismatch

解决方案:

Stream 必须 seek begin

伪代码如下:

 Stream ms = new MemoryStream();
 book.Write(ms);
 ms.Seek(0, SeekOrigin.Begin); //seek begin
 return ms;

 

以上是关于InvalidOperationException: Response Content-Length mismatch的主要内容,如果未能解决你的问题,请参考以下文章