受欢迎的博客标签

  If this is asp.net-core then you are mixing web api versions. have the action return a derived IActionResult because in your current code the framework is treating HttpResponseMessage as a model.

[Route("api/[controller]")]

public class DownloadController : Controller

{

//GET api/download/12345abc

[HttpGet("{id}"]

public async Task<IActionResult> Download(string id)

{

var stream = await {{__get_stream_here__}}

var response = File(stream, "application/octet-stream");

// FileStreamResult

return response;

}

} .