返回FileInfo HttpResult时写入标头时出错

Ric*_*ard 5 c# servicestack

我在Mono 3.x上,在Mac OSX上,我正在尝试使用ServiceStack返回一个静态文件.代码是(并且应该根据其他答案)非常简单:

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); 
    }
}
Run Code Online (Sandbox Code Playgroud)

Movie对象是一个简单的DTO.
当我的Get()被调用时,我在终端窗口中看到以下错误:

错误:处理请求时出错:[IOException]写入失败,异常:写入失败INFO:无法将错误写入响应:{0},异常:发送标头后无法更改.错误:HttpListenerResponseWrapper中的错误:写入失败,异常:写入失败

ServiceStack是版本3.9.35; Mono JIT编译器版本3.0.3(master/39c48d5 Tue Jan 8 12:12:24 EST 2013); .NET 4.5.

我究竟做错了什么?

小智 1

我在我爸爸的电脑上遇到了同样的问题,它通过使用以下方法对我有用:

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); 
Run Code Online (Sandbox Code Playgroud)