[英]Accessing up folder of publish folder at .Net Core web Api 2.1
I have .Net Core Web Api 2.1 services. 我有.Net Core Web Api 2.1服务。 I created a structure in my deployment folder like below. 我在部署文件夹中创建了一个结构,如下所示。 (I'm using IIS.) I want to access MyVariables.json
from all services. (我正在使用IIS。)我想从所有服务访问MyVariables.json
。 But, it gave error 但是,它给了错误
Could not find a part of the path 'C:\\wwwroot\\MyProject\\Shared\\MyVariables.json'. 找不到路径“ C:\\ wwwroot \\ MyProject \\ Shared \\ MyVariables.json”的一部分。
But, there is that folder and file in that path. 但是,该路径中有该文件夹和文件。 I'm trying by this code from my C# service. 我正在尝试从我的C#服务中使用此代码。
using (StreamReader file =File.OpenText(@"../Shared/MyVariables.json"))
{
}
What can be the reason of this? 这可能是什么原因?
My publish folder design 我的发布文件夹设计
-wwwroot
-MyProject
+Service1
+Service2
+Service3
+Service4
-Shared
MyVariables.json
IIS runs with an identity that is configured in the App pool. IIS使用在应用程序池中配置的身份运行。
Directory access rights must be given to the identity used to run the App pool. 目录访问权限必须赋予用于运行应用程序池的身份。
Start inetmgr.exe to configure IIS,find App Pool identity and then configure access in file explorer. 启动inetmgr.exe来配置IIS,找到应用程序池标识,然后在文件资源管理器中配置访问权限。
Reference : https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities 参考: https : //docs.microsoft.com/zh-cn/iis/manage/configuring-security/application-pool-identities
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.