在web API项目中,我有一些功能,如传递URL以供所有人查看pdf,
[HttpGet]
[Route("upload/document")]
public HttpResponseMessage GetPdf()
{
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
string fileName = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + @"Documents\test.pdf");
FileStream fileStream = File.OpenRead(fileName);
response.Content = new StreamContent(fileStream);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return response;
}
我想要像这样的url
http://localhost:54316/upload/document/test.pdf
但不应该得到url,当我在邮递员中运行时,它会得到下载。