I'm on Mono 3.x, on Mac OSX and I'm trying to return a static file with ServiceStack. The code is (and should be, according to other answers) very straightforward:
public class AirPlayService : Service
{
public object Get(Movie request)
{
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Movies", request.Name);
var file = new FileInfo(fileName);
return new HttpResult(file, asAttachment:false);
}
}
The Movie object is a simple DTO.
When my Get() gets called I see the following error in my Terminal window:
ERROR: Error occured while Processing Request: [IOException] Write failure, Exception: Write failure INFO: Failed to write error to response: {0}, Exception: Cannot be changed after headers are sent. ERROR: Error in HttpListenerResponseWrapper: Write failure, Exception: Write failure
ServiceStack is version 3.9.35; Mono JIT compiler version 3.0.3 (master/39c48d5 Tue Jan 8 12:12:24 EST 2013); .NET 4.5.
What am I doing wrong?
i had the same problem on my dad's computer, it worked for me by using :
public class AirPlayService : Service
{
public object Get(Movie request)
{
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ( "Movies", request.Name);
var file = new FileInfo(fileName);
return new HttpResult(file, asAttachment:false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With