title: BinaryWrite exception "OutputStream is not available when a custom TextWriter is used" in MVC 2 ASP.NET 4
body: <p>I have a view rendering a stream using the response BinaryWrite method. This all worked fine under ASP.NET 4 using the Beta 2 but throws this exception in the RC release: </p>
  
  <p></p>
  
  <blockquote>
    <p>"HttpException" , "OutputStream is not
    available when a custom TextWriter is
    used."
    </p>
  </blockquote>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %&gt;
  &lt;%@ Import Namespace="System.IO" %&gt;
  &lt;script runat="server"&gt;
  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();
      }
  }   
  &lt;/script&gt;
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The view is generated from a client side redirect (jquery replace location call in the previous page using Url.Action helper to render the link of course). This is all in an iframe.</p>
  
  <p>Anyone have an idea why this occurs?</p>