Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Editor / Using Session State in Custom Editor Dialogs

Using Session State in Custom Editor Dialogs

Article Info

Rating: Not rated

Article information

Article relates to

 RadEditor for ASP.NET AJAX

Created by

Stoyan Stratev


Note: If you are using version 2009.1.311 or above, then you do not need to use the workaround described in this article. The editor dialogs will work with session state without any modifications.

Starting with version 2008.2.1001, the RadEditor control no longer requires Session State to be activated in the web application. This was done in order to allow the editor to work in all application scenarios. As a result of this change, if you have customized one of the editor dialogs and are using the Session object in the code, the dialog will stop working after you upgrade to the latest release. You might see an exception with the following text:

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.

To fix this, you will need to create a new dialog handler class with enabled session for the editor popups and update your dialog handler definition in the Web.config file to point to the new class. You can put the new class in the App_Code folder of your web application:

VB.NET
Namespace CustomHandler 
  Public Class SessionStateDialogHandler 
    Inherits Telerik.Web.UI.DialogHandler 
    Implements System.Web.SessionState.IRequiresSessionState 
  End Class 
End Namespace 

C#

namespace CustomHandler 
  public class SessionStateDialogHandler : Telerik.Web.UI.DialogHandler, System.Web.SessionState.IRequiresSessionState 
  { 
  } 

The class simply inherits the default dialog handler and implements the IRequiresSessionState marker interface. To enable the new dialog handler, open the application's Web.config file and update the <httpHandlers> element. The element is located in the <system.webServer> section when running in IIS 7 Integrated Mode and in the <system.web> section in all other cases.

old definition:
IIS 6: 
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*"
type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
validate
="false"/> 
 
 
IIS 7 Integrated Mode: 
<add name="Telerik.Web.UI.DialogHandler.aspx_*"
path
="Telerik.Web.UI.DialogHandler.aspx" verb="*"
type
="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
preCondition="integratedMode,runtimeVersionv2.0" /> 

new definition:
IIS 6: 
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*"
 
type="CustomHandler.SessionStateDialogHandler, App_Code"
validate="false"/> 
 
 
IIS 7 Integrated Mode: 
<add name="Telerik.Web.UI.DialogHandler.aspx_*"
path="Telerik.Web.UI.DialogHandler.aspx" verb="*"
type="CustomHandler.SessionStateDialogHandler, App_Code"
preCondition="integratedMode,runtimeVersionv2.0" /> 

The only changed part is the type attribute. It should hold the type and assembly name of your new dialog handler. In this case the type is CustomHandler.SessionStateDialogHandler and the assembly name is App_Code. If you are using a web application project, which does not have an App_Code folder, simply replace App_Code with the name of your project's output assembly.

Comments

There are no comments yet.
If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.