Gur*_*epS 8 c# asp.net sharepoint-2010
我在以下代码(ContentType行)上收到错误(服务器无法在发送HTTP标头后设置内容类型.).我应该改变什么?
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();
Run Code Online (Sandbox Code Playgroud)
这是在Sharepoint 2010 webpart内.
尝试设置response.BufferOutput = true;.设置response变量后立即执行此操作.
看一下 HttpResponse.BufferOutput 属性
http://msdn.microsoft.com/en-us/library/33cy25ty%28v=vs.100%29.aspx
| 归档时间: |
|
| 查看次数: |
30194 次 |
| 最近记录: |