How to pull configuration settings from XML file in Startup.cs

泪湿孤枕 提交于 2019-12-01 15:25:32

问题


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)



来源:https://stackoverflow.com/questions/40036819/how-to-pull-configuration-settings-from-xml-file-in-startup-cs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!