简体   繁体   English

在asp.net核心中添加文件夹路径而不是对其进行编码?

[英]where to add folder path in asp.net core instead of harcoding it?

I have a list of folder locations in my application.我的应用程序中有一个文件夹位置列表。

How do I add folder path location in the app without hardcoding it.如何在不对其进行硬编码的情况下在应用程序中添加文件夹路径位置。

I found web.config to use appsettings but I cannot load it in my Visual studio and what is the different between appsetting.config and web config我发现 web.config 可以使用 appsettings 但我无法在 Visual Studio 中加载它,appsetting.config 和 web config 之间有什么不同

appsettings.config has replaced web.config in ASP.NET Core. appsettings.config 已替换 ASP.NET Core 中的 web.config。

appsettings.config is where you should but and confirmation information for your application. appsettings.config 是您应该保存的位置,以及您的应用程序的确认信息。

Data in appsettings.config can be accessed in the program via the IConfiguration interface, which is available as a property in the Startup class, and can be accessed in controllers etc. through dependency injection. appsettings.config 中的数据可以通过IConfiguration接口在程序中访问,该接口作为Startup类中的一个属性可用,并且可以通过依赖注入在控制器等中访问。

Full details here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1此处的完整详细信息: https : //docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM