I am trying to use ServiceStack to return a file to a ServiceStack client in a RESTful manner.
I have read other questions on SO (here and here) which advise using HttpR
You can intercept the response prior to it being handled by using a response filter, like below:
ServiceClientBase.HttpWebResponseFilter = response =>
{
if (response.Headers["Content-Disposition"] != null)
{
var t = response.DownloadText();
Console.WriteLine(t);
}
};
However, this is not the best way to handle it, since the actual call to client.Method()
will result in an ArgumentException
when the client attempts to read the response stream (since it has been read previously by response.DownloadFile(...)
. I haven't yet figured out a way to handle it gracefully, but I 'll update my answer if I do.