Will my site work in Medium Trust?

For security reasons MaximumASP recommends you run your applications in Medium Trust.

This can cause some complications for customers when developing applications locally where everything works great, and then immediately fails after you upload the content into a hosting site.

The Microsoft ASP.NET frameworks are set to run in Full trust by default when installed. Some folks are not aware of this configuration which causes the confusion mentioned above.

Here is a simple way to test your application locally before uploading it to a hosted platform.

Step 1: Test your application on your local environment
In the root web.config of your application add the following entry inside the <system.web> section.

<trust level="Medium"/>

You are telling the ASP.NET runtime that you want to run in Medium trust. If you do have issues you should begin to see them immediately during compilation, and/or while running your unit test locally.

Step 2: Deploy your application to the hosted site
At this stage you should have an application that runs great in Medium trust, or you have found the areas of your site that demand more than what the default Medium trust policy provides. If you do have issues please read the Additional Information section below if you would like to see if our trust policy will support your needs.

Before uploading your site you *must* remove the above section from the root web.config. If you do not  you will receive a nasty series of exceptions. You will receive exceptions because most all providers *lock* this configuration entry so it can only be defined at the server level to prevent you or your neighbor from trying to upgrade your trust level.

If you do not see the Configuration Error exception in your browser or logs then you need to temporarily change the customErrors mode to "Off" so you can see the true exception being thrown.

Additional Information
We have provided the information above so you can test your application locally using the lowest level of trust policy before uploading to our Cloud product, or another hosting provider.

Article ID: 746, Created On: 2/5/2010, Modified: 6/15/2010

Feedback (0)