Limit of 88 bytes on response.write?

我们两清 提交于 2019-12-12 00:33:09

问题


I am trying to serve a csv file from a wcf service, as a string response.

It looks like this:

HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=ImportErrors.csv");
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.Write(myCsvContent);

The response StatusCode is set to (int)HttpStatusCode.OK (200)

It works, but I am only getting 88 bytes of my csv and the rest is cut off (not shown).

Any suggestions on where to look? I don't see any custom entries in my web.config that are setting a limit.


回答1:


Make sure to call

HttpContext.Current.Response.Flush();
HttpContext.ApplicationInstance.CompleteRequest();

This will close the stream and flush the rest of the content.

EDIT: Check out this link. It would seem that my original information was a bit out of date... I've been in "MVC Land" for so long I've forgotten this pattern!



来源:https://stackoverflow.com/questions/13869430/limit-of-88-bytes-on-response-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!