views:

16

answers:

0

I have a RESTful web service built on the MVC framework (ala Aaron Skonnard) where methods may return > 4MB of XHTML. I don't want to bump up against the 4MB ASPBufferLimit, and so I'm planning to use the Controller.File() method as shown below -- note the "text/html" trick.

In the past, I've written a loop to pump large streams out using Response.BinaryWrite(). But the Controller.File() method uses Response.TransmitFile() under the covers, so I assume it's achieving the same effect? And is perhaps more efficient than what I would write? Is Controller.File() the right approach?

The Code:

    public ActionResult CleanReport(string protocolName, string sourceName, string reportName,
        int pageIndex, int pageSize)
    {
        ReportTable report = GetReport(protocolName, sourceName, reportName, pageIndex, pageSize);
        return File(XmlUtils.XmlSerializeToStream<ReportTable>(report), "text/html");
    }