简体   繁体   中英

How do I configure IIS or the web server to allow it to read and write files?

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 .

As 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% . Therefore, if your site runs using the 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 for an application pool (see more here ).

尝试给予Network Service用户适当的权限

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM