Search code examples
web-servicessecurity

Request for the permission of type 'System.Security.Permissions.FileIOPermission.. failed


I am getting this error when calling a web service method which writes to a file on the local drive on Windows 2003.

"System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

I have done these steps:

  • website runs in an appPool using the localSystem identity
  • website impersonates a user in the admin group.
  • the web service assembly has full trust
  • the url of the web service has full trust in the machine's web.config.
  • the folder's written to security has the impersonated user

So why is this web service still complaining about FileIOPermission? Fulltrust includes FileIOPermission.


Solution

  • After a lot of troubleshooting, it boiled down to a mistake I made in web.config where the location tag had a path of www.example.com but in IIS it was example.com!