13

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

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

My code runs proper in my local server it's create issue when upload it to server.

Have gone through following code but it's not working for me :

Sample 1 :

<system.web>
  <securityPolicy>
    <trustLevel name="Full" policyFile="internal"/>
  </securityPolicy>
</system.web>

Sample 2 :

<location allowOverride="false">
  <system.web>
    <securityPolicy>
      <trustLevel name="Full" policyFile="internal" />
      <trustLevel name="High" policyFile="web_hightrust.config" />
      <trustLevel name="Medium" policyFile="web_mediumtrust.config" />
      <trustLevel name="Low"  policyFile="web_lowtrust.config" />
      <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
    </securityPolicy>
  </system.web>
</location>

Sample 3 :

<system.web>
    <trust level="Full" originUrl="" />
</system.web>

I can't able to access IIS I have only FTP details to upload file. Please suggest me option to solve it from webconfig file.

1
  • You need write permission on app_data folder and trust level set to "high" or "full" in IIS (or admin console for web hosting). When upgrading, file permissions can get overwritten and might need a reset. Recently I've seen this error with 2.5.0.11 and had to add full trust directive to the web.config - even though IIS told me it is already full trust. Not sure why, but it fixed it. Jul 17, 2012 at 15:13

2 Answers 2

22

The approach you used in sample three is similar to my solution, but I did not add the additional attribute that you had. Try this simple approach.

  <system.web>
    <trust level="Full"/>
  </system.web>

This came from an MSDN posting I read.

0

NOTE: If you are using a shared host, they usually have a web interface to allow read/write access to files.

I don't recommend but you can impersonate a specific account:

<system.web>
    <identity impersonate="true" username="user" password="pass" />
</system.web>

Otherwise make sure you have granted proper permission to the file(s) you are trying to access to the Identity being used in your App Pool.

Specify an Identity for an Application Pool (IIS 7)

1
  • HUmm also have try above code. It's not solve my problem... thanks for suggestion. Jul 17, 2012 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.