Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
955 views
in Technique[技术] by (71.8m points)

c# - IIS - Access to the path is denied

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 'server1Folder1Folder2Folder3file1.dwg' is denied.

Here is the action which returns the error:

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

I have tried to giving permissions to "Folder3" for multiple usernames, for example "SERVER1NETWORK 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 Addvance
  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 Above things are not working then try to give same permission to NETWORK,NETWORK SERVICE Users


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...