流参数始终为空

Stream parameter is always null

我正在从我的客户端 (ASP.NET MVC) 向 webapi 服务发送 post 请求,但是,webapi 服务控制器需要一个 Stream 参数,它总是 null.

来自 ASP.NET MVC 应用程序的请求:

using(var client = new HttpClient())
{
    Token token = GetToken();
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.TokenType, token.AccessToken);
    var content = new StreamContent(stream);
    content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "keliaStream" };
    var res = client.PostAsync(GetSdcUri(), content).Result;
}

WebApi 控制器:

// POST: api/Publication
[HttpPost]
[Route("whatever-route")]
[RequireHttps]
public System.Web.Mvc.ActionResult GenerateSDCFromTBox([FromBody]Stream keliaStream)
{
    // whatever
}

keliaStream 总是空的,我错过了什么?

感谢您的评论,我找到了解决方案。
如果有人遇到同样的问题,这是我的解决方案:

客户端(ASP.NET MVC):

using(var client = new HttpClient())
{
    Token token = GetToken();
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.TokenType, token.AccessToken);
    var content = new StreamContent(stream);
    content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    var res = client.PostAsync(GetSdcUri(), content).Result;
}

服务器(WebApi):

public System.Web.Mvc.ActionResult GenerateSDCFromTBox()
{
    Stream stream = Request.Content.ReadAsStreamAsync().Result;
    // return do what ever with stream
}