我使用此代碼在我的應用程序,以顯示存儲在網絡驅動器上的一些圖像,例如與路徑// MyCompanyServer /文件夾天冬氨酸MVC IIS用戶權限
public ActionResult DocumentoLista(string area)
{
if (String.IsNullOrEmpty(area))
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var doc = db.Documentos.Where(x => x.area == area).FirstOrDefault();
if (doc == null)
{
return HttpNotFound();
}
string dirPath = Path.GetFullPath(doc.path);
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
List<string> files = new List<string>();
DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
foreach (string fInfo in Directory.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly)
.Where(s => s.EndsWith(".png")
|| s.EndsWith(".PNG")
|| s.EndsWith(".jpg")
|| s.EndsWith(".JPG")
).Select(Path.GetFileName)
)
{
files.Add(fInfo);
}
ViewBag.Area = area;
ViewBag.Dirs = dirs;
ViewBag.MyList = files;
return View(doc);
}
它完美我的開發計算機上,但當我從我的部署服務器嘗試它時,它不起作用。我認爲這可能不起作用,因爲在我的開發計算機中,我正在用我的LDAP用戶執行它,而在我的生產服務器(IIS)中,用戶是不同的,並且沒有權限訪問此路徑。 ¿可能?
女巫用戶執行asp應用程序?我需要授予哪些用戶權限才能使其工作?
感謝