Arumugam Kumarappan
Arumugam Kumarappan

Reputation: 41

IIS 7.5 Authorization Issue - Network share not accessible

I am facing a trouble in accessing a file in ASP.NET application suddenly. I am not able to access the files which lies over the share (Different server than web server).

Say, My dev machine is “A” I have files to access from Server “B”.

When I write code in asp.net, it works fine in debug mode. But when I deploy into IIS 7.5, I am getting Unauthorized exception.

Piece of code :

protected void Button1_Click(object sender, EventArgs e)
{           
    string filepath = @"\\ServerB\MyDocs\{0}"; //Here MYDocs folder is a shared folder in ServerB
    string filename = "Resume.pdf";

    string fileFullName = String.Format(filepath,filename);
    Response.TransmitFile(fileFullName);            
}

The pdf document opens up in IE when I run in debug mode but not when I deploy.

Most of the Google pages says, it would run under Application Pool Identity in IIS 7.5. But I could not figure out what else I need to modify.

Note : I’m running under Anonymous Authentication -> Application Pool Identity

Upvotes: 1

Views: 3061

Answers (2)

Arumugam Kumarappan
Arumugam Kumarappan

Reputation: 41

I found the solution for the Authentication issue.

The problem was my web server is Windows 2008 R2 and File share was in Windows 2003 server. The application running using "IIS AppPool\DefaultAppPool" identity. But this user is not available in Windows 2003 Server.

I changed the identity of my application pool to “Network Service” and give the permission to “NetworkService” user in 2003 server. Now I am able to open the files application.

I found this useful info in this site : http://www.element-it.com/OnlineHelpHTTPCommander/Windows/ntfs.html

Upvotes: 1

Mazhar Karimi
Mazhar Karimi

Reputation: 157

Try one of the following.

Create a network drive, and use its drive letter

string filepath = @"Z:\{0}";

Try google and search for "network dirve mapping". you would find plenty of results.

Or you can give access rights to the user which is running the Application Pool.

And check if you are not using Classic mode of Application Pool.

Upvotes: 0

Related Questions