0

I have a pdf file on a windows server running IIS7 that I use as a template to create a printable/offline version of my web form. I access it in an APS.NET application using an .ashx handler. Initially it worked fine, until I moved to Production, then it gave me Access to the path 'D:\inetpub\site\My PDF.pdf' is denied.

First I tried changing the App Pool identity, in case it was a permissions issue. I also added full control permissions for that identity. Doing this broke it in the lower environment as well. When the app pool was switched back to the original(ApplicationPoolIdentity), it still didn't work.

I'm finding the file via HttpContext.Current.Server.MapPath, which works as expected. Then I'm using FileStream existingFileStream = new FileStream(fileNameExisting, FileMode.Open) to open the file for editing via iTextSharp. The file has permissions for 'Network Service'.

Any help would be appreciated. Let me know if you need more information.

I apologize if this is the wrong site for this question. If it is, please let me know and I will move it to the proper one.

EDIT:

Below is the the permissions via icacls of the file in the production environment. MYDOMAIN, CustomAppIdentity, WEBSERVER, and LabManagers have names changed for security.

MYDOMAIN\CustomAppIdentity:(F)
NT AUTHORITY\NETWORK SERVICE:(F)
NT AUTHORITY\Authenticated Users:(I)(RX)
NT AUTHORITY\SYSTEM:(I)(F)
WEBSERVER\LabManagers:(I)(M)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
NT SERVICE\TrustedInstaller:(I)(F)

EDIT: Event Information

Event code: 4011 
Event message: An unhandled access exception has occurred. 
Event time: 7/1/2015 11:07:56 AM 
Event time (UTC): 7/1/2015 6:07:56 PM 
Event ID: 9c4a06e4465744da8d76e27f3d954c30 
Event sequence: 48 
Event occurrence: 3 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/8/ROOT/MyProject-1-130802388056279071 
    Trust level: Full 
    Application Virtual Path: /MyProject 
    Application Path: D:\inetpub\parent-site\MyProject\ 
    Machine name: MYSERVER 

Process information: 
    Process ID: 4236 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\MyProject 

Request information: 
    Request URL: http://parentsite.url/MyProject/PdfHandler.ashx 
    Request path: /MyProject/PdfHandler.ashx 
    User host address: 159.1.15.73 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\MyProject

Custom event details: 
9
  • What are the permissions on that file? Can you add the result of icacls.exe "D:\inetpub\site\My PDF.pdf" Jul 1, 2015 at 2:32
  • @PeterHahndorf I've added it at the end.
    – Chloe
    Jul 1, 2015 at 15:33
  • Looks like there are enough permissions there. If you have a quiet time on the server, I would run Process Monitor to check for Access Denied. Jul 1, 2015 at 16:20
  • You can verify if this is a permissions issue by (temporarily!) giving the Everyone group access to the file.
    – Joel Coel
    Jul 1, 2015 at 18:22
  • @JoelCoel I have Everyone full control. It still says System.UnauthorizedAccessException: Access to the path 'E:\inetpub... etc...' is denied..
    – Chloe
    Jul 1, 2015 at 18:45

1 Answer 1

0

The handler PDFHandler.ashx had the wrong language, vb rather than c#, which was causing the exception. This was not a server problem, it was simply throwing a misleading error. So far, this has fixed the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .