This is a migrated thread and some comments may be shown as answers.

Session State not available in Application_PreRequestHandlerExecute when using RadScriptManager

2 Answers 134 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pivetal
Top achievements
Rank 1
Pivetal asked on 23 Oct 2008, 11:37 AM
Using the following code in an aspx page:

<body>
    <form id="form1" runat="server">
    <div>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
</div>          
    </form>
</body>

and in a Global.asx codebehind:

public class Global : System.Web.HttpApplication
    {        
        void Application_PreRequestHandlerExecute(object src, EventArgs e)
        {
               Session["test"] = "Test";
        }
    }

I get an HttpException error saying that "Session state is not available in this context".

Thanks in advance and I hope this is enough information and for reference my web.config file is as follows:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>

    <connectionStrings/>
    <system.web>
        <pages enableEventValidation="false" theme="DefaultTheme" />
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true">
            <assemblies>
                <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                <add assembly="Telerik.Charting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=D14F3DCC8E3E8763"/>
                <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>

        <httpHandlers>
            <remove path="*.asmx" verb="*" />
            <add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
               validate="false" />
            <add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
               validate="false" />
            <add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
               validate="false" />            
            <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.826.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
               validate="false" />
        </httpHandlers>

        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    </system.web>
</configuration>







2 Answers, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 23 Oct 2008, 02:16 PM
Hi Bleddyn,

I think that the error you receive is not directly related to RadScriptManager but rather to the specifics of the availability of the Session object inside the Application_PreRequestHandlerExecute handler in Global.asax under NET 2.x. Review this public forum thread which elaborates on this subject and provides a solution:

http://www.velocityreviews.com/forums/t282576-aspnet-20-session-availability-in-globalasax.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pivetal
Top achievements
Rank 1
answered on 24 Oct 2008, 10:00 AM
Thanks
Tags
General Discussions
Asked by
Pivetal
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Pivetal
Top achievements
Rank 1
Share this question
or