ASP.NET WebAPIでファイル(FileContentResult)を返す方法
通常のMVCコントローラーでは、pdfをで出力できますFileContentResult。 public FileContentResult Test(TestViewModel vm) { var stream = new MemoryStream(); //... add content to the stream. return File(stream.GetBuffer(), "application/pdf", "test.pdf"); } しかし、どうすればそれをに変更できApiControllerますか? [HttpPost] public IHttpActionResult Test(TestViewModel vm) { //... return Ok(pdfOutput); } これが私が試したものですが、うまくいかないようです。 [HttpGet] public IHttpActionResult Test() { var stream = new MemoryStream(); //... var content = new StreamContent(stream); …