简体   繁体   English

ASP.NET appsettings.json 在我的项目中不存在

[英]ASP.NET appsettings.json does not exist in my project

I am following this guide on how to create a Web API with ASP.NET Core and MongoDB.我正在关注如何创建一个Web API 与 ASP.NET 内核和 Z206E3718AF092FD1D12F08C I have followed every step successfully up until the Add a configuration model section .我已成功完成每一步,直到添加配置 model 部分 In the guide, I need to locate appsettings.json and add database configuration values to my project.在指南中,我需要找到appsettings.json并将数据库配置值添加到我的项目中。 The problem is that the file they mention appsettings.json does not exist in my project.问题是他们提到的文件appsettings.json在我的项目中不存在。

In the guide, its implied that the file should already exist and should even already have content in it, so I don't know if I should just create it.在指南中,它暗示该文件应该已经存在,甚至应该已经包含内容,所以我不知道是否应该创建它。

I have looked online and all over my project but nothing seems to be definitive on what is the right thing to do (some guides contradict each other, etc.).我已经在网上查看了我的项目,但似乎没有什么是正确的做法(一些指南相互矛盾等)。

Apart from the default ones, I explicitly installed have the following NuGet packages:除了默认的,我明确安装了以下 NuGet 包:

  • Microsoft.Extensions.Configuration (I thought this might help, but it didn't) Microsoft.Extensions.Configuration (我认为这可能会有所帮助,但没有)
  • MongoDB.Driver (the instructions on the guide said to) MongoDB.Driver (指南上的说明说要)

My setup is the following:我的设置如下:

  • Microsoft Visual Studio Community 2019 Version 16.4.6 Microsoft Visual Studio 社区 2019 版本 16.4.6
  • Microsoft .NET Framework Version 4.8.03752微软 .NET 框架版本 4.8.03752
  • ASP.NET and Web Tools 2019 16.4.462.24200 ASP.NET 和 Web 工具 2019 16.4.462.24200
  • ASP.NET Web Frameworks and Tools 2019 16.4.462.24200 ASP.NET Web 框架和工具 2019 16.4.462.24200

I have closed and re-opened VS but that didn't change anything.我已经关闭并重新打开了 VS,但这并没有改变任何东西。

This is my solution explorer:这是我的解决方案资源管理器:

Should I just create the file?我应该只创建文件吗? In the guide, it already has content in it.在指南中,它已经包含了内容。 What about that?那个怎么样?

Is there a new/different way of add database configuration values to my project?是否有一种新的/不同的方式可以将数据库配置值添加到我的项目中?

Is the guide outdated?指南过时了吗? If it is completely unusable, can you point me to a newer guide on how to Create a web API with ASP.NET Core and MongoDB?如果它完全无法使用,您能否向我指出有关如何使用 ASP.NET07792FDCAFDA1?

Thank you very much!非常感谢!

The app exists for ASP.NET core projects.该应用程序适用于 ASP.NET 核心项目。 You mistakenly created, I believe, an ASP.NET framewok project.我相信您错误地创建了一个 ASP.NET 框架项目。 The tutorial is about the ASP.NET core.本教程是关于 ASP.NET 内核的。

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

相关问题 ASP.NET Core 应用程序不会从输出目录中读取 appsettings.json,而是从项目一中读取 - ASP.NET Core app does not read appsettings.json from output directory, but from the project one 如何在另一个项目的上下文中阅读 appsettings.json? ASP.NET 核心 - How to read appsettings.json in context in another project? Asp.Net Core 使用ASP.NET Core反序列化appsettings.json - Deserialize appsettings.json with ASP.NET Core ASP.NET Core appsettings.json 更新代码 - ASP.NET Core appsettings.json update in code ASP.NET核心EF代码首先appsettings.json - ASP.NET Core EF Code First appsettings.json ASP.NET Core appsettings.json 未加载正确的设置 - ASP.NET Core appsettings.json not loading the correct settings 用于 MSTest [ASP.NET Core 3.1] 的 appsettings.json - appsettings.json for MSTest [ASP.NET Core 3.1] AppSettings.json用于ASP.NET核心中的集成测试 - AppSettings.json for Integration Test in ASP.NET Core ASP.NET Core appsettings.json需要在磁盘上更新 - ASP.NET Core appsettings.json need to update on disk Serilog:RollingFile 在带有“appsettings.json”的 asp.net 核心中不起作用 - Serilog : RollingFile is not working in asp.net core with 'appsettings.json'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM