【发布时间】:2016-09-04 07:24:54
【问题描述】:
文件系统中有成功上传的图像,我想访问它。所以,我写了GET-method
[HttpGet]
public ActionResult Get(string id) {
var path = $@"d:\smth\upload\{id}.jpeg";
return File(path, "image/jpeg");
}
我完全确定在所需路径中存在具有所需名称的文件,但任何时候尝试创建 File(path, "image/jpeg") 我都会得到 Could no find file 异常。好像我无权访问wwwroot 之外的文件夹。也许我错过了working with static file article 的重要内容?
那么,谁能解释一下如何通过GET-method 返回存储在网络服务器文件夹外的文件系统中的图像
【问题讨论】:
-
下次请使用正确的标签,以获得正确的答案! asp.net-mvc 标签适用于旧的 MVC webstack!为 ASP.NET Core MVC 使用 asp.net-core-mvc!!
标签: c# asp.net-core asp.net-core-mvc