1

I am using the PDFsharp (which is used to generate pdf file in asp.net), and got an error "Access to the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\Tax_receipt.pdf' is denied."

I guess it is trying to write file to this folder so I tried to add an ASPNET account with write permission to that folder. I use "computer name\ASPNET" which can't be found and "Network Service" which didn't work.

Does anyone know how to add permission?? Many thanks!!

edit:

I use MemoryStream instead of FileStream finally, and this will avoid to create physical file.

pita
  • 537
  • 4
  • 15
  • 35

1 Answers1

1

My guess is that you are hosting on IIS v7.5.

If this is the case, you need to grant ACL permissions to the application pool identity of the application pool to which your asp.net application is assigned.

For example, if you have assigned your IIS application to the Default Application pool (DefaultAppPool) you need to grant the permissions to IIS AppPool\DefaultAppPool (make sure the IIS server machine name is selected as the location).

Here are some related resources:

An MS support article

A similar question on SO

Community
  • 1
  • 1
Pencho Ilchev
  • 3,201
  • 18
  • 21
  • Sorry I forgot to mention that I am still developing the site, so it is on my computer, there is not any application pool – pita Jul 19 '12 at 17:45
  • Are you using the VS web development server? When you debug your application what is the URL in the address bar of the browser? – Pencho Ilchev Jul 19 '12 at 17:48
  • llchev localhost:12345/pages/..... I read the code, it actually use filestream method to write pdf file, so I changed the default file path to the desktop and it works, but I guess I can't do this once I deploy the site to the server – pita Jul 19 '12 at 17:55
  • You are using the web server built into Visual studio. By design it runs under your windows account with the permissions granted to VS. Run Visual studio as an administrator and it should work. When you deploy to production, make sure that you grant the ACL permissions as described in the answer. – Pencho Ilchev Jul 19 '12 at 18:11