1
votes

When i try to browse a .Net code page, it shows the following exception :

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.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

then I tried this:

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

It shows the following error:

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using from an inherited configuration file.

Somewhere i read that

These settings are predefined by hosting service that's why you can't define the setting in web.config.

Now how should i make it work !

Thanks in advance.

3

3 Answers

1
votes

try this

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

I found the solution, actually it was because of SSL. I have below SSL related code in my application. I commented the code and uploaded and it worked.

ServicePointManager.ServerCertificateValidationCallback = delegate(some patameterws) { return true; };

I also asked for help from my hosting service and it said:

You can only run medium trust ASP.NET on our hosting. As Medium Trust is the highest trust level we permit, ensure your application does not violate Medium Trust rules (for example, attempting to set the trust level in a web.config file, even if you are defining it as medium, is not permitted in medium trust). If you do actually need full trust level, or anything higher than the medium trust we offer, you will need to find another provider – if you do actually need full trust, you may need a Windows VPS provider. We do not change this setting for you, nor do we allow you to change it on your end.

Thought It may help others so decided to post it here.

0
votes

I fixed this solution in my website

in your local Visual studio try adding following lines to web.config

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

then run your application(website) locally which will throw exception catching line number of exception in detail

for example mine was, I was trying to access Local file using fileIO class

I commented that code and website runs fine with medium trust.

Hope this works