Bas*_*sie 5 c# iis permissions windows-7 asp.net-core-mvc
我正在使用此代码将文件上传到(Windows 7)服务器
[HttpPost]
public IActionResult Upload(string office, IFormFile file)
{
var webRootPath = _environment.WebRootPath;
var floorPlanPath = _configuration["SydneyFloorplanPath"];
if (file.Length > 0) {
var filePath1 = Path.Combine(floorPlanPath,webRootPath.ReplaceFirst("/", ""));
using (var fileStream = new FileStream(filePath1, FileMode.Create)) {
file.CopyTo(fileStream);
}
}
return RedirectToAction("Index", new{office = office});
}
Run Code Online (Sandbox Code Playgroud)
在 VSCode 中调试时效果很好,但发布后我得到
UnauthorizedAccessException: 拒绝访问路径“C:\inetpub\wwwroot\LogonChecker\wwwroot”。
上new FileStream线了。。
我在 Windows 7 上使用 IIS 6.1。