AjaxToolkit IIS7 Asp.Net 4.0: Sys is not defined; handler mapping issue?
Asked Answered
F

3

6

I have moved my asp.net 3.5 app to asp.net 4.0 and moved from windows 2003 (iis6) to windows 2008 r2 (iis7.5) and now i have this sys is undefined error.

i have the app running in an integrated application pool. everything works except my ajaxtoolkit 3.0.20820.0 dll

now I have read several blog posts, most of them cover asp.net 2.0 web.config files and not the minimized asp.net 4.0 config files.

here are some parts from my current config file:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
    <add name="AjaxToolkit" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  />
</handlers>

and another part:

<httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
    <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>

There is not much info available for asp.net 4.0 and ajaxtoolkit http handler issue, so I hope some guru @ stackoverflow can help me out :)

EDIT:

since I have this stupid sys undefined thing, my global.asax gives this on_Error:

Error Message: This is an invalid script resource request.
Stack Trace:
at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context) 
at System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) 
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

it's on scriptresource.axd files :S

Edit2: the strange thing is that my local web.config hasn't got any handler stuff in the web.config and it runs on the development webserver casini

Edit 3: people say that Adrian has the solution here: http://budigelli.wordpress.com/2007/05/01/error-sys-is-undefined-error/ but I can't get it to work on IIS7

Edit 4: I've read somewhere that IIS7 has a wildcard mapping at Handler mapping I have seen that there is an extensionless wildcard mapping in de sorted list above the .axd mapping. but now I still don't know how to configure the mappings in IIS7 to support the Ajaxtoolkit!

Flower answered 29/9, 2010 at 14:43 Comment(0)
F
4

OK solved it: I found this comment of Cassiano at this URL: http://madskristensen.net/post/Optimize-WebResourceaxd-and-ScriptResourceaxd.aspx

and then I realized that I had the URL rewriting extension in IIS7 which appended a trailing slash to everything. (the rule was generated by the wizard of the rewriting component)

here is my current web.config parts which i used and had ajaxtoolkit to work:

<httpHandlers>
    <remove verb="*" path="*.asmx" />
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
    <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>

and this part:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
        <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated" />
        <add name="test jp" path="*.axd" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>

rule number 10 : AjaxToolkit IIS7 Asp.Net 4.0: Sys is not defined; handler mapping issue?

Flower answered 4/10, 2010 at 8:37 Comment(3)
JP, I have seen this solution but it is for ASP.Net 3.5. If you notices in the web.config you posted the version of ScriptResource.axd is 3.5.0.0. This may still work but it is referencing the 3.5 libraries instead of the 4.0 libraries. -JeremyPostliminy
Hi Jeremy, it was an 3.5 web app which was migrated to 4.0. sorry that i've left out that info. but how should the references be for a 4.0 dll? and can i safely migrate the ajaxtoolkit from 3.5 to 4?Flower
As far as I've seen so far, yes. Refer to my answer above.Postliminy
P
17

For asp.net 4.0 on IIS 7 and IIS 7.5 add this to your web.config:

<system.webServer>
            <handlers>
                <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            </handlers>
</system.webServer>

UPDATE: I have changed the version to the correct version for ASP.NET 4.0

Postliminy answered 29/9, 2010 at 21:45 Comment(2)
Hello Jeremy, are you sure it should be version 1.0? the strange thing it that the same webapp works locally on my windows 7 x64 asp.net 4 (with build in dev.webserver) but doesn't work remote on IISFlower
JP, You are right, it should be version 4.0.0.0 not 1.x. I fixed the above to reflect that.Postliminy
F
4

OK solved it: I found this comment of Cassiano at this URL: http://madskristensen.net/post/Optimize-WebResourceaxd-and-ScriptResourceaxd.aspx

and then I realized that I had the URL rewriting extension in IIS7 which appended a trailing slash to everything. (the rule was generated by the wizard of the rewriting component)

here is my current web.config parts which i used and had ajaxtoolkit to work:

<httpHandlers>
    <remove verb="*" path="*.asmx" />
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
    <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>

and this part:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
        <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated" />
        <add name="test jp" path="*.axd" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>

rule number 10 : AjaxToolkit IIS7 Asp.Net 4.0: Sys is not defined; handler mapping issue?

Flower answered 4/10, 2010 at 8:37 Comment(3)
JP, I have seen this solution but it is for ASP.Net 3.5. If you notices in the web.config you posted the version of ScriptResource.axd is 3.5.0.0. This may still work but it is referencing the 3.5 libraries instead of the 4.0 libraries. -JeremyPostliminy
Hi Jeremy, it was an 3.5 web app which was migrated to 4.0. sorry that i've left out that info. but how should the references be for a 4.0 dll? and can i safely migrate the ajaxtoolkit from 3.5 to 4?Flower
As far as I've seen so far, yes. Refer to my answer above.Postliminy
P
0

In the past we used the ASP.NET AjaxToolkit and the template, demo, or example files shipped which a web.config with the following

      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Platy answered 20/1, 2016 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.