IIS 7 and Above
Permission denied to write file to a folder
Last post Dec 21, 2013 06:02 AM by ServerIntellect_JB
Dec 20, 2013 03:12 PM|mdivk|LINK
I am using Windows 2008 for IIS server, my app will allow users to upload file to a folder.
The app is running under a special pool using a special id, the id has been granted write privilege to the folder, I am still getting error:
12/20/2013 2:35:17 PM,Error uploading file: C:\inetpub\wwwroot\AOR\Doc\xxxx.pdf,System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\AOR\Doc\xxxx.pdf' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at System.Web.HttpPostedFile.SaveAs(String filename)
I don't have this issue on my local laptop running windows 7 (IIS6.1). I am thinking if I need to add ASPNET to the folder but: 1. there is no ASPNET in IIS 7 on Windows 2008; 2. I am using a special account to run the app
what's missing here? how do I fix it? Thank you very much.
Dec 21, 2013 06:02 AM|ServerIntellect_JB|LINK
The permissions that .NET requires to write into a folder are generally write permissions to the directory for the application pool identity.
If the identity shows as ApplicaitonPoolIdentity in the application pools secion of IIS, then you would use "IIS AppPool\[appool name]"
Since you are using a special identity, make sure that the specific user has write access to the folder.
Another possibility is that you may need access for the identity on the .NET framework's temporary directory.
This will generally be at "C:\Windows\Microsoft.NET\(Framework/Framework64 de[ending on your application)\[Version]\Temporary ASP.NET Files"
Hope this helps