在asp.net网络应用中,从远程服务器共享目录中访问文件的问题。

问题描述 投票:0回答:1

Asp.net网络应用程序在IIS服务器上托管,在共享同一网络的其他服务器上访问共享目录中的文件,得到错误信息。

[Access to file path "\ServerName\some/folder\on/disk/file.txt" is denied"].我给了IISUser,MachineUser,直到Everyone的权限,但是没有结果。

但当我从同一服务器的IIS中的一个实用程序(POC)访问路径时,它访问路径并下载字符串,但从Web应用程序中却返回错误。

string filepath = @"\\ServerName\some\folder\on\disk\file.txt"
using(Webclient client = new Webclient())
{
  filetext = client.DownloadString(filepath)
}
asp.net iis web-applications webclient-download
1个回答
0
投票

拒绝访问文件路径"\ServerName/some/folder/on/disk/file.txt "的原因是你的应用池身份没有权限访问共享文件夹,请将应用池身份替换为你的域账户,并确保域账户有权限访问共享文件夹。

enter image description hereenter image description hereenter image description hereenter image description here

© www.soinside.com 2019 - 2024. All rights reserved.