1

I've been running in circles with allowing my application to write to a folder on a shared network drive.

So far I have this:

FileUploadControl.SaveAs(Server.MapPath("myFolder/" + filename));

this successfully saves the file to

\\machineName\inetpub\wwwroot\myApp\myFolder

However, I am also trying to save the same file to a folder outside of the root folder on the path

\\machineName\myFolder

using:

FileUploadControl.SaveAs("C:\\myFolder\\" + filename);

This returns an error of "Access Denied." So how do I go about allowing my application to write a file to \\machineName\myFolder? I have tried giving write permissions to IIS_IUSRS and NETWORK SERVICE to no avail. Should I create a user with privileges to write to the network drive and then use impersonation to use that user when writing to the drive? Using IIS 7 with .NET 4 application.

KidBatman
  • 585
  • 1
  • 13
  • 27
  • have you tried running as admin? oh and I remember having to give permissions for a username that was specific to the application pool like IIS_[app pool name here]... don't forget to turn those permissions off – RadioSpace Feb 05 '14 at 00:27
  • If the answer below doesn't work, you can try programatically changing permissions, as I [showed in this SO post](http://stackoverflow.com/a/18623931/1810243). – MikeSmithDev Feb 05 '14 at 02:05

1 Answers1

7

Go to your application's app pool, right click on it and choose Advanced properties. Check the Identity value under Process model settings group. Give this Identity permissions to write files in your folder.

If the value is ApplcationPoolIdentity than user name is IIS APPPOOL\app_pool_name.

Anri
  • 6,175
  • 3
  • 37
  • 61
  • Hey @Anri, thanks for the reply. When I attempt add a user/group name into the object names box, I get the "Name Not Found" dialog. I have been attempting to add IIS APPPOOL\ASP.NET v4.0 Classic> I'm going to mess around with it a little bit more to see what I am doing wrong. – KidBatman Feb 06 '14 at 16:15
  • Still unable to add permissions for IIS APPPOOL\app_pool_name. I have tried @MikeSmithDev solution with no luck as well. Can anyone provide further insight? – KidBatman Feb 06 '14 at 19:06
  • @user2596756 you realise `app_pool_name` is just a placeholder for your real application pool name, right? – Anri Feb 06 '14 at 19:12
  • yes. In my first comment I detail that I tried to add IIS APPPOOL\ASP.NET v4.0 Classic – KidBatman Feb 06 '14 at 19:20
  • @user2596756 try this answer http://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity – Anri Feb 06 '14 at 19:53