我在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);
}
}
Movie对象是一个简单的DTO 当我的Get()被调用时,我在终端窗口中看到以下错误:
错误:处理请求时出错:[IOException]写入失败,异常:写入失败 信息:无法向响应写入错误:{0},异常:发送标头后无法更改。 错误:HttpListenerResponseWrapper出错:写入失败,异常:写入失败
ServiceStack是版本3.9.35; Mono JIT编译器版本3.0.3(master / 39c48d5 Tue Jan 8 12:12:24 EST 2013); .NET 4.5。
我做错了什么?
答案 0 :(得分: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);