Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
Hi all,
I m trying to upload file on sever through upload control. code is working fine in local environment. also i have test code in asp. But when i have deployed the same asp.net code on server, getting this error....


Access to the path 'e:\Inetpub\herddealers.com\wwwroot\admin\resources\Book1.xls' 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 'e:\Inetpub\xyz.com\wwwroot\admin\resources\Book1.xls' 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.


code in asp to upload file in same folder is working fine but not in asp.net.

can any 1 know the reason...
plz help me to resolve this issue...

Posted

1 solution

Jain Vijay wrote:
I m trying to upload file on sever through upload control. code is working fine in local environment. also i have test code in asp. But when i have deployed the same asp.net code on server, getting this error....

Vijay,

This is the problem with Access permissions on web server. Let me discussed it in details.

Why it was working on Local Environment ?

Becuase, In VS, you application is running by ASP.NET Engine, which having the all rights to write data on your system, so its working fine on Local Enviroment.

Why not in Hosted Server ?

Web Appliction runs on server with some limited permission for security reasons and user does not have the suficient permission to write data on Folder. So you are getting the Error.

Resolution :

1. Give the Full Access rights to all the user on the folder where you are storing the file.
2. Create a Separate Application Pool on Web server, Change the Identity of Application pool to "Local System" ( Which having the maximum permissions) .
And assigned it to your virtual directory.


Hope this details explained will help you :-D

 
Share this answer
 


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