开发者

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

开发者 https://www.devze.com 2023-01-12 08:03 出处:网络
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 开发者_JAVA技巧functi

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 开发者_JAVA技巧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).


Try giving appropriate permissions to Network Service user


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消