Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS - Access to the path is denied

Tags:

This question have been asked like million times, but I have tried those solutions and still can't find out why this error is coming up:

Access to the path '\server1\Folder1\Folder2\Folder3\file1.dwg' is denied.

Here is the action which returns the error:

    public ActionResult Download(string fileName)     {         fileName = fileName + ".dwg";         string path = Path.Combine(@"\\server1\Folder1\Folder2\Folder3\", fileName);         return File(path, "application/octet-stream", fileName);     } 

I have tried to giving permissions to "Folder3" for multiple usernames, for example "SERVER1\NETWORK SERVICE" - Full Control.

Application is running under Default Web Site. Application is running under DefaultAppPool and DefaultAppPool has identity of "NetworkService".

Following code gives identity "NETWORK SERVICE".

WindowsIdentity identity = HttpContext.Request.LogonUserIdentity; 

The application was working fine (same download directory) on my own computer, but after deploying this problem showed up.

Server is running Windows 2008 R2 SP1 and IIS 7.5.

like image 360
Chopman Avatar asked Feb 06 '15 07:02

Chopman


People also ask

What does it mean access to path denied?

You may see “Access to the path is denied” error if the application is not able access to a path that is trying to read or write. This will show up as 401 Unauthorized error in IIS logs.

How do I allow access to a shared folder in IIS?

In the IIS Manager , select the Application Pool under which your Web Site is running. Click "Advanced Settings". There will be an entry for Identity (it is under the Process Model section). Click it, provide credentials for your account that has permission to access the share.

How do I fix access denied on Windows 10?

Right-click the file or folder, and then click Properties. Click the Security tab. Under Group or user names, click your name to see the permissions you have. Click Edit, click your name, select the check boxes for the permissions that you must have, and then click OK.


2 Answers

Try this:

"Access to the path 'xxxxxx' is denied."

As error says you need to assign permissions to folders

  1. Right Click Folder
  2. Go to Security Tab
  3. Click on Edit
  4. Click on Add
  5. Click on Advanced
  6. Find Now
  7. Give Permission to IIS_IUSRS (Full Control)
  8. Click On OK
  9. Click On OK
  10. Click On Full Control in allow
  11. Click On OK
  12. Again Run the Application

Note: if these steps are not working, then try to give same permission to NETWORK, NETWORK SERVICE users

like image 120
Ganesh Avatar answered Sep 22 '22 16:09

Ganesh


For my case, I went to the root folder of my project, right clicked on it and opened the properties window and unchecked the Read-only attribute. After clicking OK, all started working.

like image 24
Nurhak Kaya Avatar answered Sep 22 '22 16:09

Nurhak Kaya