Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: MVC Functions that return a File: OutputStream is not available when a custom TextWriter is used.

$
0
0
We have an existing MVC app that has an Action on a controller that returns a file for download, however when we use this same action as an MVC Function in C1, we get the following error.

"Error: OutputStream is not available when a custom TextWriter is used."

Here are the code snippets.
From the View inside the C1 website
@Html.ActionLink("download", "DownloadReport")
in the the controller
public ActionResult DownloadReport()
{
          byte[] content = null;

            ///... bunch of code that builds the report in memory
            ///...
            ///...
        
           /// send the byte array content back down the wire to the client

            return File(content, System.Net.Mime.MediaTypeNames.Application.Pdf, "Report.pdf");
}
If we change ActionResult to FileResult as the return type, the MVC Function will not appear in the page. No error is logged.

Is there a way to have C1 understand this Controller Action is not returning a View, but rather a File for download?

Other suggestions?

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>