简体   繁体   English

访问.Net Core Web Api 2.1上的发布文件夹的文件夹

[英]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.

相关问题 .NET Core 在发布中包含文件夹 - .NET Core include folder in publish 发布 ASP.NET Core MVC 2.1 项目时将文件 (geckodriver.exe) 复制到发布文件夹 - Copy file (geckodriver.exe) to publish folder when publishing ASP.NET Core MVC 2.1 project 从 React Native 访问 ASP.NET Core 2.1 Web API 时“无法对 HTTPS 连接进行身份验证” - 'Failed to authenticate HTTPS connection' while accessing ASP.NET Core 2.1 Web API from React Native 访问.net核心库中的文件夹 - accessing folder inside .net core library 对于.NET Core,Visual Studio会发布忽略Views文件夹中的.js文件 - Visual Studio publish ignores .js files in Views folder, for .NET Core Net Core 3 - 在 web api 之外访问 DBContext - Net Core 3 - Accessing DBContext outside of the web api 在 Web Api Controller (.Net Core 2.1) 中获取声明和订阅 - Get claims and subscription in Web Api Controller (.Net Core 2.1) .NET Core(2.1)Web API动态命名到控制器操作的路由 - .NET Core (2.1) web API dynamic naming of routes to controller actions .NET Core 2.1 Web API是否支持基于约定的路由? - Does .NET core 2.1 web API support convention based routing? Asp.net core 2.1 web api中的自定义授权 - Custom Authorization in Asp.net core 2.1 web api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM