ASP.Net "Access to the path '' is denied."File Upload Control not Working in Web Server (IIS7)

19,988

Solution 1

This is a permission issue and you already have a hint :

To grant ASP.NET access to a file, right-click the file in File 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.

  1. Explore to IIS manager.
  2. Expand Sites node and find your site then right click.
  3. Click Explore and you will be redirected to the physical file path.
  4. Right click the folder and go to security tab
  5. Click Edit button (another window will pop up)
  6. In this window add the iis user normally it is prefix with IIS_MACHINENAME
  7. Set full permission to this user and you are good to go.

Solution 2

I struggled with this same issue and while we did all the permission changes shown I was still getting the error. In the end I wrote a small test page using the file upload control and when I tried it with various files it worked fine.

What I discovered was that there was a slight difference between these two file names and that was causing the error

  • this_file1.ppf
  • thisfile1.pdf

Yes, the underscore was causing the access violation error and for the life of me I do not know why? This also applies to files with a space in the file name. We are running the webserver (IIS7) on a Windows Server 2012 R2 if that makes a difference.

I did not find any reference to this in the control though it will fail on long file names as well.

Solution 3

Fixed mine by:

  1. File properties
  2. Under the security tab click add
  3. Add the iis user which is in my case IIS_IUSRS and then click Check Names
  4. Click OK and grant full-access from the permissions category

If you cant find IIS_IUSRS you can always go to Security > Add > Advanced > Find Now to find the IIS username.

I've also added the current logged in user by typing in the current logged in username and granted full-access

Share:
19,988
moonlight04
Author by

moonlight04

Updated on June 04, 2022

Comments

  • moonlight04
    moonlight04 almost 2 years

    I'm currently developing a website application and one of its features is to be able to upload and download the files. All the uploaded files will be stored in the external network location. First is on page load, it will create a temporary folder and all of the uploaded files will be stored there. Then when they click the save button, it will create a folder where it will be permanently stored and put all the files in the folder and remove automatically remove the temporary folder. It is working fine in my local host server, but when I upload it and put to web server, it throws an error, Access to the path '(network path)' 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 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , 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 File 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.

    I've researched for a solution for almost a week now and it says it's something about permission, but all of the solutions on the net are not clear and doesn't work for me. I hope someone could help me with the step by step instruction on how to configure permissions to be able to allow network access o any possible working solutions.

    UPDATE: Here is the current screenshot:

    Permission for the web site in IIS7

    Permission for the web site in IIS7

    I hae downloaded the ASP.NET components but I can't find the ASP.NET account. I have .net 4.0 application pool. Should I give permission on my uploading folder? Please help me.

    Thank you everyone.