views:

37

answers:

3

I'm trying to add functionality to a simple web service that will allow me to log information to an XML file on the hard drive where the application is located. When I employ the functionality in a Console version of the application, the data gets logged to:

bin\x86\Debug MySolution.MyProject\MessageLog\TestMessagess.xml.

However, when I try to write read from or write to the XML file in the ASP.NET application, I get a System.UnauthorizedAccessException with the message:

Accees to the path 'MessageLog' is denied.

I would like the log file to appear in the \bin folder of the application directory, so what settings in IIS or on the server itself would I need to change to allow my application to read from and write to that folder?

My Machine: I'm using Windows XP SP3 with ASP.NET 4.0.

+1  A: 

This is a function of the server's security, not of IIS. From within Windows Explorer, browse to the folder or file and set the security to allow the user that IIS runs under to have access.

Russ
That makes sense. I tried adding full control for the *Internet Guest Account* and the *ASP.NET Machine Account* in the `\bin` folder and then subsequently the root folder of the application. However, neither of those seemed to do the trick. Am I looking in the wrong place?
Ben McCormack
The default user that IIS runs under is the "Launch IIS Process Acount". this is the one you should set. Be sure to reset the Internet Guest account access back to what it was.
Russ
+1  A: 

Ass Russ said you need to grant read/write permission to a user which used by IIS.

For IIS up to 6.0 the identity name is NETWORK SERVICE.

For IIS 7.0 permissions are to be granted on per application pool basis. The identity template is IIS APPPOOL\%POOL-NAME%. So if your site runs using on MyApp application pool you should grant read/write access to the IIS APPPOOL\MyApp user identity. That's the default behavior. You can also set a custom identity to an application pool (see more here).

Ihor Kaharlichenko
Excellent answer, much thanks!
Ben McCormack
+1  A: 

Try giving appropriate permissions to Network Service user

Claudio Redi