防止 ASP.NET Core 应用程序使用 appsettings.json 文件
我想告诉 ASP.NET Core 应用程序,即使 appsettings.json
文件存在 - 忽略它。
I would like to tell to ASP.NET Core application that even if appsettings.json
file is there - ignore it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我更愿意将其写为评论,但我仍然是这里的新手,所以我不能提出问题。
我想了解一下您现在面临的具体问题是什么。
一般来说,是否使用 appsettings 文件取决于您的应用程序。
例如,如果您使用默认的 .NET 模板创建 Web API,您可以看到 appsettings 文件只有一些日志记录配置,您甚至可以将其删除,但什么也不会发生。无论如何,您都可以运行该应用程序并且它可以工作。
所以,回到你的问题,这取决于你的应用程序在做什么。如果您有一个特定的库需要从此文件读取配置,那么您需要研究如何更改该默认值。
如果您正在读取该文件,那么您可以在代码中设置值。 (这是显而易见的,但由于您没有提供更多背景信息,我不知道您在挣扎什么)
I would prefer to write this as a comment but I'm still a newby here so I cannot ask questions.
I would like to understand what is the specific problem you are facing right now.
In general the usage or not of the appsettings file depends on your application.
For example, if you create a Web API using default .NET template, you can see that the appsettings file only has some configuration for logging, which you can even delete and nothing happens. You can run the application anyway and it works.
So, coming back to your question, it dependes on what your application is doing. If you have a specific library that needs to read configuration from this file, then you'll need to research how to change that default value.
If you are reading from that file, then you could set value in code instead. (this is obvious but since you didn't provide any more context I don't know what you are struggling with)