0

I am trying to develop an asp application(my asp solution is in c:\inetpub). i need a logger. So I create inside my solution a folder Logs and I try to save there a *.log file:

   using (FileStream fs = File.Create(logPath))
        {...}
  // logpath = Server.MapPath(@"~\Logs") + Path.DirectorySeparatorChar + logName
  // so: logpath =  C:\\inetpub\\wwwroot\\MyApplication\\Logs\\MyLog.log

I get the error:

 Access to the path 'C:\inetpub\wwwroot\MyApplication\Logs\MyLog.log' is denied.

Is there a solution for this? I need that the installer to be able to provide acces to inetpub... I am asking also if is this the wrong way to create a log? Maybe exist a pattern used for that ...? Thank you

4

2 回答 2

1

您需要将写入权限授予 asp.net 用户。通常是Network ServiceIUSR

如果您正在运行 IIS7,请确保检查应用程序池的Identityunder advanced settings

有关更多信息,请查看:应用程序池标识

于 2013-06-28T08:07:23.220 回答
1

确保 inetpub 目录允许对内置IUSR帐户的读/写权限。

于 2013-06-28T08:03:49.503 回答