I have a problem with this ASP.NET API controller.
response.Content = new PushStreamContent(video.WriteToStream,
new MediaTypeHeaderValue("video/" + ext));
And I get this error :
Error CS0121 The call is ambiguous between the following methods or properties: 'PushStreamContent.PushStreamContent(Action, MediaTypeHeaderValue)' and 'PushStreamContent.PushStreamContent(Func, MediaTypeHeaderValue)'
TVStream G:\TVStream\TVStream\Controllers\Api\VideosController.cs 19 Active
And here is the signature of my WriteToStream method:
public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
答案 0 :(得分:2)
您应该将void
方法更改为返回Task
,这有点代表异步void
方法。
public Task WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
我不确定为什么会这样,但如果你想坚持你的async void
签名,你可以使用中间变量:
Action<Stream, HttpContent, TransportContext> writeToStream = WriteToStream;
response.Content = new PushStreamContent(writeToStream, new MediaTypeHeaderValue("video/" + ext));