0

I generate PDF files from HTML page through wkhtmltopdf (using Process from C#).

On local system (Windows 7) it's works, but on Windows Server 2008 R2 I have "System.IO.FileNotFoundException". wkhtmltopdf executed by Process (C#) not have enough permission to write file.

I tested a lot of folders (in example: "APPDIR/Content/temp"), but I have no idea what should I do.

Adrian
  • 29
  • 1
  • 5

1 Answers1

1

The process your application runs as, has to have sufficient permissions to write to a folder.

Your (most likely judging by ASP.NET tag) website can be configured to run as any user you want in IIS management console.

By default the application pool runs as ApplicationPoolIdentity and to grant access permissions to it you would use: IIS AppPool\ApplicationPoolName account.

You can also change the application pool to run as another account and configure folder permissions for that account instead.

You will have to type the full account name in the box as search is an Active Directory feature and doesn't work as expected for local accounts (In Select Users or Groups dialog)

enter image description here

LukeP
  • 10,422
  • 6
  • 29
  • 48
  • I don't have "IIS AppPool\\***" account in folder permission box. – Adrian Aug 27 '12 at 20:56
  • @Adrian Updated my answer. You will have to add this user to the list. – LukeP Aug 27 '12 at 21:47
  • Thanks for reply. I added by icacls c:\XYZ /grant "IIS APPPOOL\DefaultAppPool":(OI)(CI)(RX) (also as full control permision). I used cmd because in GUI I can't find IIS APPPOOL\DefaultAppPool. But it still doesn't work. wkhtmltopdf can't write file to folder (from C# I can write, but wkhtmltopdf from Process can't). Any idea? – Adrian Aug 30 '12 at 14:30
  • I stop saving file to a disk, and use: http://stackoverflow.com/questions/2791981/how-to-use-wkhtmltopdf-exe-in-asp-net#comment2886641_2833871 but my question still is open. Maybe some day a need to save PDF to a disk? – Adrian Aug 30 '12 at 14:42
  • It was a issue with wkhtmltopdf. I reinstalled and it's works as well! I grant access through icacls and it's ok. Thanks for help! – Adrian Aug 30 '12 at 15:16