views:

16

answers:

2

Hi,

I have a webservice, in which I read the settings saved in an xml file. I read the setting by the following command:

        string dpath = HttpContext.Current.Request.PhysicalApplicationPath.ToString();
        XmlTextReader reader = new XmlTextReader(dpath + "Settings.xml");

This is working perfectly when running the application on the localhost, but when I publish the webserver I am getting an error, most probably because the settings are not being loaded.

Am I using the right command to read the file ? thanks

A: 

It doesn't look like the wrong command on the surface, although I'd verify all paths before making that assumption. Try logging the path to a file or the event log. Enterprise Library or Log4Net should help you there. I recommend the former.

Odds are the real reason you're not able to load the file is due to permissions. I'd be willing to bet that the account under which the web server executes doesn't have the necessary permissions to open the file.

Randolpho
A: 

Why not use the web.config?

More than likely the user that the web service is running under does not have I/O access to the physical drive. You'll need to go to the directory on the server and give it permission to the appropriate user. The user will differ based on what operating system and version of IIS you're using.

Jeremy