加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 写入httpResponse时,响应是否有大小限制?

发布时间:2020-12-15 17:24:44 所属栏目:百科 来源:网络整理
导读:我正在ASP .Net C#中动态生成CSV文件,并将其直接写入响应. private void ExportToResponse(string textCsv,string fileName) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "text/csv"; HttpContext.Current.Respons
我正在ASP .Net C#中动态生成CSV文件,并将其直接写入响应.

private void ExportToResponse(string textCsv,string fileName)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "text/csv";
        HttpContext.Current.Response.ContentEncoding = Encoding.Unicode;
        HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename=" + fileName + ".csv");
        HttpContext.Current.Response.Write(textCsv);
        HttpContext.Current.Response.End();
    }

在大多数情况下,这种方法效果很好,但在某些情况下我会收到错误(“此网站无法在Internet Explorer中显示”).我怀疑原因是这个文件响应很大.在这种情况下,如何扩展响应长度的限制?

我希望我能在web.config文件中执行此操作,类似于将mexRequestLength属性设置为httpRuntime-element的方式(http://msdn.microsoft.com/en-us/library/e1f13641.aspx) .

谢谢!

解决方法

有关此问题,请参阅以下Microsoft的知识库文章

http://support.microsoft.com/kb/812406

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读