Modifying or Editing the Config File

In order to add permissions, you can edit the exiting web_mediumtrust.config file or create a custom policy file based on the medium trust policy. If you modify the existing web_mediumtrust.config file, all Web applications will have the same permissions with the permissions you have added. If you want applications to have different permissions, you can instead create a custom policy based on medium trust.

Edit the Config File

In order to add permissions, you can edit the exiting web_mediumtrust.config file. To edit the exiting web_mediumtrust.config file, complete the following steps:

1.   Locate the medium trust policy file web_mediumtrust.config located by default in the %windir%\Microsoft.NET\Framework\{Version}\CONFIG directory.

2.   Open the web_mediumtrust.config file.

3.   Add the permissions that you want to grant. For examples, see Adding Permissions.

Create a Custom Policy Based on Medium Trust

In order to add permissions, you can create a custom policy file based on the medium trust policy. To create a custom policy file, complete the following steps:

1.   Locate the medium trust policy file web_mediumtrust.config located by default in the %windir%\Microsoft.NET\Framework\{Version}\CONFIG directory.

2.   Copy the web_mediumtrust.config file and create a new policy file in the same directory.

Give the new a name that indicates that it is your variation of medium trust; for example, AllowReflection_Web_MediumTrust.config.

3.   Add the permissions that you want to grant. For examples, see Adding Permissions.

4.   Enable the custom policy file on your application by modifying the following lines in your web.config file under the <system.web> node:

<system.web>

<trust level="CustomMedium" originUrl=""/>

 

 <securityPolicy>

                 <trustLevel name="CustomMedium" policyFile="AllowReflection_Web_MediumTrust.config"/>

          </securityPolicy>

          ...

</system.web>

Note: Your host may not allow trust level overrides.  Please check with your host to see if you have these rights.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.