服务器无法设置内容类型后,HTTP标头已被送往 [英] Server cannot set content type after HTTP headers have been sent
本文介绍了服务器无法设置内容类型后,HTTP标头已被送往的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在以下code得到一个错误(HTTP标头之后被送往服务器无法设置内容类型。)(的ContentType
线)。我应该怎么改?
I get an error (Server cannot set content type after HTTP headers have been sent.) on the following code (ContentType
line). What should I change?
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(PervasiveConstants.DownloadZipLocation) + ";");
response.TransmitFile(PervasiveConstants.DownloadZipLocation);
response.Flush();
response.End();
这是一个SharePoint 2010的WebPart内。
This is within a Sharepoint 2010 webpart.
推荐答案
尝试设置 response.BufferOutput = TRUE;
。为此设置应答后,立即
变量。
Try setting response.BufferOutput = true;
. Do this immediately after setting the response
variable.
这篇关于服务器无法设置内容类型后,HTTP标头已被送往的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文