Learner
Learner

Reputation: 786

Opening a folder from web application using C# giving access denied

I have used the following code to open the folder from the server on my screen through ASP.Net MVC 5.0 web application hosted on IIS 7.5 on the same server, server is using windows 8.

public void OpenFolder()
{
    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() {
        FileName = "\\SERVERNAME\Public\Lists",
        UseShellExecute = true,
        Verb = "open"
    }); 
}

This is opening the folder fine when I am running my application in development, Whereas giving Access denied error when in production.

I have given all permissions to IUSR and IIS_IUSRS to the folder along with Administrators, Users, Network, Network service and few other users. But still no luck.

If somebody has faced the same problem before or know how to resolve the issue then please throw some light and guide me to the way. Also, I am not good at networking side.

Upvotes: 3

Views: 990

Answers (2)

David Harkness
David Harkness

Reputation: 11

Try giving the app pool identity (IIS AppPool\DefaultAppPool - replace DefaultAppPool with the name of your app pool if different) permissions on the folder. See this link- http://devonenote.com/2010/09/grant-permission-to-defaultapppool-identity/

Upvotes: 1

Richard
Richard

Reputation: 109140

In development (using something like IIS Express) the process running your code runs as your login account.

But once deployed it will run as whatever account the IIS application pool is configured as.

Note also that IUSR etc. are local accounts; this will be treated as guest when connecting to network resources (like a share). For that you'll need to run the application pool as a domain account (or local account on both machines with matching username and password).

Upvotes: 5

Related Questions