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

三世轮回 提交于 2021-01-20 09:12:53

问题


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.


回答1:


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!




回答2:


Finally we have found the issue. After building the files in Windows we put them in a zip file. When the files are added to the zip windows adds a blocking property to all files which remains after unzipping the folder. These caused the files to not be able to run properly. The "block" property can be removed by right-clicking on the files (one at the time), select "Properties" and then clicking the "Unblock" button at the bottom. Here is an example picture:

https://www.howtogeek.com/wp-content/uploads/2011/08/image10.png

To prevent windows from adding this blocking property, one can look at the following thread:

Can I stop windows from “Blocking” zip files



来源:https://stackoverflow.com/questions/1085860/request-for-the-permission-of-type-system-security-permissions-fileiopermission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!