1
我試圖使用內存流生成PDF。當清除標題時,它會投擲Server cannot clear headers after HTTP headers have been sent
。這是我的代碼片段。Context.Response.Headers'拋出了類型'的異常System.PlatformNotSupportedException
Context.Response.Clear();
Context.Response.ClearHeaders();
Context.Response.ClearContent();
System.IO.MemoryStream st = new System.IO.MemoryStream();
st = (MemoryStream)levyStream;
byte[] b = st.ToArray();
Context.Response.AppendHeader("Content-Disposition", "inline; filename="+MyFilename);
Context.Response.AppendHeader("Content-Length", b.Length.ToString());
Context.Response.BufferOutput = true;
Context.Response.ContentType = "application/pdf";
Context.Response.Charset = "";
Context.Response.OutputStream.Write(b, 0, (int)st.Length);
Context.Response.Flush();
st.Close();
我在響應對象中附加了一個錯誤。
問候, 阿魯娜
想知道如果你只在IE11面臨這一點。您是否嘗試過其他瀏覽器?你找到了解決方案嗎? – Par6