7

I simply have a web api application on IIS server that simply writes to text file on C:\FileStorage\test.txt however when I call this webservice I get the internal 500 error, after expanding the error,I get the following error, how do I grant write access to this web service on IIS server?

"ExceptionMessage": "Access to the path 'C:\\FileStorage\\test.txt' is denied.",
"ExceptionType": "System.UnauthorizedAccessException",
"StackTrace": "   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n   at 
user1429595
  • 2,635
  • 9
  • 25
  • 30

2 Answers2

18

Grant permissions for that folder to the application pool. So you'd go to the C:\FileStorage folder in Windows and edit permissions, and add IIS APPPOOL\appPoolNameHere as a user, then give it full permissions.

Hope that helps.

EDIT

Step by Step Instructions...

-Open Windows Explorer

-Browse to your folder

-Right click the folder and go to Properties

-On the Security tab click Edit

-Click Add

-Under Locations, make sure it is pointing at your local machine, not a domain

-For the object name, enter below but replace MyAppPool with the name of your application pool...

IIS APPPOOL\MyAppPool

-Set the permissions to Full, or just add Write, or whatever you need.

Jim
  • 6,753
  • 12
  • 44
  • 72
0

or you can repalce APPPOOL to the name of your server or computer and with the IIS_ISURS. example:

yourserver\IIS_IUSRS

See this Screen Shot

screenshot

ascripter
  • 5,665
  • 12
  • 45
  • 68