我有一个使用响应BinaryWrite方法渲染流的视图.这一切都在ASP.NET 4使用Beta 2工作正常,但在RC版本中抛出此异常:
“HttpException”,“OutputStream is not
available when a custom TextWriter is
used.”
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <%@ Import Namespace="System.IO" %> <script runat="server"> protected void Page_Load(object sender,EventArgs e) { if (ViewData["Error"] == null) { Response.Buffer = true; Response.Clear(); Response.ContentType = ViewData["DocType"] as string; Response.AddHeader("content-disposition",ViewData["Disposition"] as string); Response.CacheControl = "No-cache"; MemoryStream stream = ViewData["DocAsStream"] as MemoryStream; Response.BinaryWrite(stream.ToArray()); Response.Flush(); Response.Close(); } } </script> </script>
视图是从客户端重定向生成的(jquery替换前一页中的位置调用,使用Url.Action帮助程序渲染链接当然).这一切都在一个iframe中.
任何人都有一个想法为什么会发生这种情况?