Now if I rightclick the folder, and select properties/security, myApplicationPool is appeared there with only "special permissions" allowed. And when I try to upload something it will give me an unauthorizedexception..
What is the proper way to give the write rights to this folder?
leposima
0 Points
1 Post
how to programmatically give write rights for application pool to certain folder for uploading fi...
Jan 23, 2013 12:49 PM|LINK
Hello
I have an asp.net application, hosted by iis in c:\inetpub\wwwroot\myApp
I try to programmatically give my application rights to write uploaded files to c:\inetpub\wwwroot\myApp\app_data\upload
I did that by following method:
DirectoryInfo dInfo = new DirectoryInfo(path);
DirectorySecurity dSec = dInfo.GetAccessControl();
dSec.AddAccessRule(new FileSystemAccessRule( "IIS APPPOOL\\myApplicationPool" , fileSystemRights.FullControl, accessControlType.allow));
dInfor.SetAccessControl(dSec);
Now if I rightclick the folder, and select properties/security, myApplicationPool is appeared there with only "special permissions" allowed. And when I try to upload something it will give me an unauthorizedexception..
What is the proper way to give the write rights to this folder?
I tested on Win8/IIS8/IE10
Thanks,
Leposima
Pengzhen Son...
Star
8276 Points
848 Posts
Microsoft
Re: how to programmatically give write rights for application pool to certain folder for uploadin...
Jan 24, 2013 07:54 AM|LINK
Hi,
In my opinion, this way is impossible. Maybe you should manually set the permission througth web.config or iis.
Please refer this
http://stackoverflow.com/questions/11958200/secure-and-automated-way-of-giving-permissions-for-upload-folder-in-asp-net-c-sh
http://www.codeproject.com/Articles/18072/Allow-your-ASP-NET-to-Access-your-Resources
http://stackoverflow.com/questions/8765044/write-permission-for-a-specific-folder-in-web-config
Hope it can help you.
Feedback to us
Develop and promote your apps in Windows Store