System.UnauthorizedAccessException: Access to path is denied

2.5k views Asked by At

Good afternoon, I have recently purchased a server with Plesk 12 as the Control Panel. I don't have much experience using Plesk.

For testing purposes, I created a simple ASP.NET project which tries to read/write from a txt, as shown below:

String logPath = @"C:\inetpub\vhosts\xxx.com\httpdocs\log_application_error.txt";
StreamWriter textWriter = new StreamWriter(logPath, true);

When the StreamWriter instance is created, I get the following error:

System.UnauthorizedAccessException: Access to the path 'C:\inetpub\vhosts\xxx.com\httpdocs\log_application_error.txt' is denied.

I tried granting read/write permissions to the txt file, and even granted Full Control to "Everyone", but the result was the same.

Plesk seems to hide everything so that it is handled through the Control Panel. I don't see any Applications Pools on the IIS so I am not even sure what is the identity it is running under.

Any help would be greatly appreciated.

2

There are 2 answers

2
Oleg Neumyvakin On BEST ANSWER

Try to set "Additonal write/modify permissions" at "Hosting settings" of your domain:

Plesk write permissions

1
IgorG On

Try to fix it with following commands:

cacls C:\Windows\assembly\GAC_MSIL /E /R psacln /T /C

cacls C:\Windows\assembly\GAC_MSIL /E /R psaadm /T /C