简体   繁体   中英

Allow write permissions for .NET application

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM