Victor
Victor

Reputation: 260

Inetpub -acces denied?

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

Upvotes: 0

Views: 628

Answers (2)

Vishal Suthar
Vishal Suthar

Reputation: 17194

You need to give the write permission to the asp.net user. Typically it is Network Service or IUSR.

If you are running IIS7 make sure to check the Identity under advanced settings of the application pool.

For more information look into this: Application Pool Identities

Upvotes: 1

chead23
chead23

Reputation: 1879

Make sure the inetpub directory allows read/write permissions to the built in IUSR account.

Upvotes: 1

Related Questions