0

i'm having a few throubles resolving an issue. I have to read data from webconfig file

<AmountsList>
  <Amount>
    <Id>1</Id>
    <Value>20</Value>
    <Operator>Vodafone</Operator>
  </Amount>
  <Amount>
    <Id>2</Id>
    <Value>30</Value>
    <Operator>Vodafone</Operator>
  </Amount>
</AmountList>

I've already look up for a solution but i coulnd't find anything that work as requested, and i'm still a noob in webservices.

My Problem is in setting up webconfig file with the data. I know that in a normal situation this shouldn't be in this file, but this is a request.

  • As you pointed out, the web.config file should store settings which control how your website works. Therefore you could create a XML-file and store it in The App_Data folder. Please see this post on how to retrieve data in the XML-format: http://stackoverflow.com/questions/7119806/c-sharp-reading-data-from-xml – Philip Sep 22 '15 at 16:46

2 Answers2

2

Check out custom configuration sections - https://msdn.microsoft.com/en-us/library/2tw134k3.aspx

You can then add a custom section to the app config, which you can then read / write to accordingly.

DotNetHitMan
  • 931
  • 8
  • 20
1

Another option is to load the web.config file as a pure XML file and get required information from there. You can use XDocument or XmlDocument classes for this task.

XDocument config = XDocument.Load("web.config");
Vova
  • 1,356
  • 1
  • 12
  • 26