This chapter describes the procedure of running Kentico CMS in Medium Trust Level environment and the steps required to configure the system for it. It also describes the Precompilation/Deployment procedure and requirements.
Medium trust level
Medium trust level is often used on shared servers by the providers to disallow the applications to access certain resources that could be harmful to other websites running on the server. Kentico CMS can be used with default medium trust policy provided with the Microsoft .NET Framework. To run the system with medium trust, you need to follow certain rules. There are two main components that require higher than medium trust and must be considered in this situation:
|•||VirtualPathProvider – provides virtual objects (layouts, transformations) from the database.|
|•||Content staging module – ensures synchronization of content between production and live site servers.|
Virtual path provider
This library provides the interface for virtual objects stored in the database that can be compiled, such as document transformations and page layouts. The system references the files with virtual path, and VirtualPathProvider provides the control code to the compiler.
Since the virtual provider cannot run in a medium trust environment (requires AspNetHostingPermission with "high" trust level), you need to store the physical files to the file system. You can save all the virtual objects to the file system in CMS Site Manager -> Administration -> System -> Deployment interface by clicking the button “Save all virtual objects to disk”. This will make the copies of the virtual objects in following folders:
|•||~/CMSTransformations - contains transformation files for documents and custom tables|
|•||~/CMSLayouts - contains shared page layouts|
|•||~/CMSTemplateLayouts - contains custom page template layouts|
|•||~/CMSAdhocTemplateLayouts - contains custom ad-hoc page template layouts|
Please note that these files are just copies of the actual virtual object and will be used by the system only if the VirtualPathProvider cannot start. Also that the changes to the objects through the administration interface will not affect these files until you save all the objects to the disk again.
In the medium trust environment, the VirtualPathProvider is stopped automatically. When VirtualPathProvider is stopped, you cannot edit transformations and layouts through the user interface without saving them on the disk again.
In the portal development model, you cannot use custom web part code (Web part properties –> Code tab). If you need to add custom code on the Code tab and run the website in the medium trust environment, you need to create user controls, place web parts to the user controls and add your custom code to the web parts. Then, you can place the user controls to the page using the General/User control web part.
Please not that you shouldn't run the system in medium trust while developing the website. You should use this trust level only for the live website.
Content staging (Microsoft Web Services Extensions 3.0)
This section applies only if you're using content staging.
Library Microsoft.Web.Services3.dll from the Web Services Extensions 3 (WSE) package which is used by the Content staging module requires Full trust permissions because of the low level operations related to the communication protocols. To ensure the proper functionality, the library needs to be registered in the Global Assembly Cache (GAC) of the server. The library is provided by Microsoft and most of the hosting providers pre-install it on their shared servers.
If you manage the server, please follow these steps:
|1.||Go to Control panel -> Administrative tools -> Microsoft .NET Framework 2.0 Configuration.|
|2.||Select the Assembly cache, click on Add an Assembly to the Assembly Cache and select the bin\Microsoft.Web.Services3.dll library file from your web project.|
|3.||Delete the bin\Microsoft.Web.Services3.dll file from your web project if it's present.|
|4.||Make sure that your project web.config file contains the following item:|
<compilation debug="false" numRecompilesBeforeAppRestart="100">
If your hosting provider cannot install the library to GAC, you need to manually remove some of the system components. See the paragraph Special cases for details.
Running the website
Now the system should work under medium trust level properly. Restart your IIS for configuration changes to take effect and run the website.
If your website uses any third-party components that do not support medium trust level by default, you may need to configure the system for them. In this case, please contact their author to get the information how to configure the environment to run it in the medium trust environment.
You may not be able to access the GAC or convince your hosting provider to add the WSE library to the GAC. In this case, you may still run Kentico CMS in medium trust level, but you will not be able to use the Content staging module.
If this is your case, please delete the bin/Microsoft.Web.Services3.dll file from your web project if it's present
After these changes, your system will work correctly in the medium trust environment but you will not be able to use the Content staging operations.