UnauthorizedAccessException with IIS7

混江龙づ霸主 提交于 2019-12-23 19:22:47

问题


I'm trying to write a log file from an ASP.NET application under IIS7, but keep getting the following exception:

UnauthorizedAccessException "Access to the path 'C:\Users\Brady\Exports' is denied."

I have given write access to the iis_iusrs, iis_wpg, and aspnet users, based on various advices found by Google, but still get the error. Can someone please explain how I can create a log file in that directory, or, will creating a log directory under the web application itself automatically allow writing the file, and is this not perhaps a better solution?


回答1:


You need to grant permission to one of the following accounts

ASPNET - Win XP and Win 2000
NETWORK SERVICE - Win Vista and 2003

These are the defaults, if the application pool has been configured for a different process account then you would need to work with that specific account.




回答2:


I think Mitchel's got it, but I'll add that troubleshooting these kinds of things is infinitely easier using SysInternals' Process Monitor (FileMon for legacy systems) to take away the guesswork/trial and error.




回答3:


If you are Impersonating some other user in ASP.NET, that user account must have permission to write to that directory. I highly recommend not setting a user's personal folder path as the location to store a web application's log or data. That requires the ASP.NET worker process account to have access to that user's private folder, if they are not the same account.

Allocating a common area, for example D:\webapps\logapp\logfiles, is encouraged. With the appropriate permissions given, of course.



来源:https://stackoverflow.com/questions/188114/unauthorizedaccessexception-with-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!