Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi ALL,

i developed one application asp.net with c# in VS2005.
in that Application i m using PDF to show reports.

when i run locally its working PDF working fine but when i deployed in iis7 then i m getting error call acess denied.
THIS IS ERROR.............
......................................................

Access to the path c:\SADEmpty.pdf is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'c:\SADEmpty.pdf' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Posted

In web.config file of your application provide the impersonate details.
as bellow.
Ex:
<identity impersonate=&quot;true&quot; userid="domainName\username" password="password"/>;.

Then provide permission to the specified identity user to the specific folder U added the file.
Here files should be places in any specific folder to which u need to provied permission.
 
Share this answer
 
Hi,

problem is, that asp.net doesn't have permission to the file, which is located directly on c:\.
add rights to NETWORK SERVICE, IIS_IUSRS

Regards
Robert
 
Share this answer
 
Provide appropriate or full rights to the folder wherever you are trying to write a PDF file.

Please verify following rights on folder like:
ASPNET
IWAMUSER
NETWORK


Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 
Comments
tungnx_vn 1-Mar-11 22:31pm    
alo
The problem is that you are trying to create a pdf file in the root of the C: drive.

Do you need to create a file at all? I don't know what you're using to generate the pdf's, but you may be able to do it in memory.

If you need to create a file, I would suggest putting it in a subdirectory of your application root. To get a full path, use Page.MapPath.

Nick
 
Share this answer
 
you need to change the permission of your directory to enable in IIS 7 configuration :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900