How to add a xml in web.config?

前端 未结 3 1258
暖寄归人
暖寄归人 2021-01-13 06:52

I have some complex data which is used for application configuration in xml format. I want to keep this xml string in web.config. Is it possible to add a big xml string in w

3条回答
  •  一向
    一向 (楼主)
    2021-01-13 07:05

    There are several ways of achieving what you want (an XML fragment that is globally and statically accessible to your application code):

    • The web.config is already an XML file. You can write a custom configuration section (as described here) in order to fetch the data from your custom XML.

    • You can encode the XML data (all < to <, > to >, & to &, " to "e;)

    • You can put the XML data in a section

    • Don't use web.config for this, but a Settings file as @Yuck commented

    That last option is the best one, in terms of ease of development and usage.

提交回复
热议问题