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:
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!