The ASP.NET Capsule #13: Preparing your Telerik based website to run in medium trust

Today I installed a new website for one of our customers in a shared hosting provider (I will omit the name because I think is one of the worst shared hosting providers available, cheap but crappy).

In any case, virtually every single shared hosting provider works on medium trust or some sort of security level near the medium trust and only a few of them provides full trust as an add-on or upgrade.

So, after setting up the database I uploaded all the necessary files and that’s when this error came into play:

Telerik_Error_MediumTrust

Of course I was surprised at first but after reading carefully I came to realize that all I needed was to change the base class my pages inherit from. The class is the RadAjaxPage.

Taken from the documentation:

This class is required as a base class for any page that hosts a RadAjaxManager control and runs under Medium trust privileges.

Now, not all pages needs to inherit from RadAjaxPage. Only pages that use RadControls which in turn use the RadAjaxManager control are in need of this.

Also taken from the documentation:

AJAX Manager is one of the two major controls of the Telerik RadAjax suite. The other one is AJAX Panel. AJAX Manager allows developers rapidly develop powerful and complex AJAX solutions.

The main features of AJAX Manager are:

  • You can ajaxify all controls that normally work with postbacks.
  • Defines visually and codeless (in Visual Studio design-time) which elements should initiate AJAX requests and which elements should be updated
  • No need to modify your application logic
  • Allows you to update a number of page elements at once regardless of their position on the page.
  • No need to write any JavaScript or invoke AJAX requests manually

So, a code behind file for a page that would normally look like this:

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.UI;
   6:  using System.Web.UI.WebControls;
   7:   
   8:  namespace Some.Web
   9:  {
  10:      public partial class SomeForm : System.Web.UI.Page
  11:      {
  12:          protected void Page_Load(object sender, EventArgs e)
  13:          {
  14:   
  15:          }
  16:      }
  17:  }

would change to:

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.UI;
   6:  using System.Web.UI.WebControls;
   7:  using Telerik.Web.UI;
   8:   
   9:  namespace Some.Web
  10:  {
  11:      public partial class SomeForm : Telerik.Web.UI.RadAjaxPage
  12:      {
  13:          protected void Page_Load(object sender, EventArgs e)
  14:          {
  15:   
  16:          }
  17:      }
  18:  }

And that will do the trick.

The bad news is that still, Telerik Reporting doesn’t work in medium trust, so let’s hope this feature will be included in the near future.

Enjoy!

4 Comments

  • DevExpress' XtraReports work in medium-trust environments...

  • XtraReports is also extremely crippled under medium-trust, Anon. :)

  • If you're an AJAX nvicoe and are defied by AJAX, then you may want to try AJAX Webshop because it features IDE and visualization and allows beginners to develop Rich Web applications quickly. Let's look at some of its features: Based on standard component library it allows Ajax IDE in the pattern of rapid application development (RAD)Integrated development and management tools are available. Easy-to-use visual Unified Modeling Language and visual IDE; complete component and object-oriented development patternRich Web component libraryTroubleshooting IntelliSense support, code editing support, project release and deployment support.Java, PHP, C#, VB supportCompatible with IE, Firefox

  • This could be one of the most cpnmelliog post I ever read in a long time, I'm speaking about this section of your article it also made me think about the day I ran into my husband.

Comments have been disabled for this content.