簡體   English   中英

DirectoryInfo僅從localhost查找路徑

[英]DirectoryInfo only finds path from localhost

我有一個DirectoryInfo變量聲明如下:

DirectoryInfo rootDirectory = new DirectoryInfo(@"\\server01\Shared\Saved Stuff\");

當我從localhost運行我的網站時,以下代碼返回true,但是當我發布並上傳它時,它返回false。

bool doesItExist = rootDirectory.Exists;

我不相信(實際上我確信)這是一個安全權限問題,因為我給實體“Everyone”完全訪問目標文件夾。 任何人都有一個線索,為什么這可能發生,只有在現場? 僅供參考,當我將桌面遠程連接到server01並輸入上述路徑時,我可以毫無問題地訪問它,就像我可以從本地機器一樣。

假設您正在為您的網站使用Windows身份驗證...

您很可能遇到“NTLM一跳” - 從其他計算機傳遞到服務器的憑據無法重用以訪問第三台計算機,因此未經過身份驗證的用戶正在訪問\\ server01 \\ shared。

要確認 - 嘗試在部署代碼的服務器上使用瀏覽器導航到使用此代碼的頁面。

嘗試這個

DirectoryInfo rootDirectory = new DirectoryInfo(HttpContext.Current.Server.MapPath(@"\\server01\Shared\Saved Stuff\"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM