I have a startup.cs file and i want to pull configurations from XML file rather than appsetings.json
file. Is it possible with ASP.NET Core MVC?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to use an appsettings.xml
instead you can refer to my blog article here.
Quote from the article:
To use XML files, you need to add this NuGet package: Microsoft.Extensions.Configuration.Xml. I added the 1.0.0 to my project.json and added a appsettings.xml file.
<configuration> <MySettings> <SomeSetting>Test</SomeSetting> <Another>true</Another> </MySettings> </configuration>
I then added it as part of configuration like this:
.AddXmlFile("appsettings.xml", optional: true, reloadOnChange: true)