ServiceStack and returning a stream

Yes returning an IHttpResult will allow you to control the exact payload, Content-Type and other HTTP Headers as you wish.

Also you’re not limited to returning a stream, i.e. you can use the HttpResult to return an xml string with a different Content-Type.

Here are some links that better demonstrate what’s possible with ServiceStack return types:

You can also return a static File using a FileInfo object, with an optional parameter to return the file as an attachment which will prompt the user to download the file rather than attempt to view it in the browser with:

return new HttpResult(new FileInfo("~/static-response.xml"), asAttachment:true);

Leave a Comment