title: How to render response stream with jquery?
body: <p>I have this </p>
  
  <pre><code>    MemoryStream export = new MemoryStream();
      iCalendarSerializer serializer = new iCalendarSerializer(iCal);
      serializer.Serialize(export,System.Text.Encoding.UTF8);
      return export;
  </code></pre>
  
  <p>so I am using the C# DDay.iCal library for exporting my calendars. Serialize takes in a "stream" so I passed it a memory stream.</p>
  
  <p>I now have a generic handler that calls the method that contains the above code.</p>
  
  <pre><code> public class CalendarHandler : IHttpHandler
      {
          private Calendar service;
          private Membership membershipS;
  
          public void ProcessRequest(HttpContext context)
          {
              service = new Calendar ();
              membershipS = new Membership (null);
              string userName = context.User.Identity.Name;
              Guid userId = membershipS.GetUsersId(userName);
  
              context.Response.ContentType = "text/calendar";
              // calls the export calendar(the code that showed above that uses dDay ical.
              var t = service.ExportCalendar(userId);
  
              t.WriteTo(context.Response.OutputStream);
  
          }
  
          public bool IsReusable
          {
              get
              {
                  return false;
              }
          }
      }
  </code></pre>
  
  <p>So now I wrote the icalendar to the Outputstream. Now I have a jquery post that goes to this method and now I am not sure how to take the OutputStream result that the jquery post will get and make it popup with a save dialog box.</p>
  
  <pre><code>$('#ExportCalendar').click(function(e)
  {
      $.post('../Models/CalendarHandler.ashx', null, function(r)
      {
  
      });
  
      return false;
  });
  </code></pre>