Sunday, October 21, 2012

There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

Last time I got the following error:
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
See in the image below the following config error, and also watch the config source.
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
Root of the error
I got the error when I was deploying a web application precompiled in asp.net 2.0 onto the production server with asp.net 4.0. The simple search reveals that it is known issues with VS 2010 and asp.net 2.0. But my site is asp.net 2.0 enabled. What's the root of the error then?  
My conclusion (and please correct me if necessary)
I have configured asp.net web extension namespaces in my web.config file. You don't see this in asp.net 3.5 and 4.0 enabled sites since servers with asp,net 3.5/4.0 by default server asp.net ajax services. But asp.net 2.0 has to be ajax enabled by installing asp.net ajax extension 1.0 which you can download from here. Sensed duplicate entry of system.web.extension section group? Yes, don't include the following section group in the config section if your site runs on asp.net 2.0 but published on asp.net 3.5/4.0.

  1.       
  2. <configsections>  
  3.     <sectiongroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  4.       <sectiongroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  5.         <section allowdefinition="MachineToApplication" name="scriptResourceHandler" requirepermission="false" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  6.         <sectiongroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  7.           <section allowdefinition="Everywhere" name="jsonSerialization" requirepermission="false" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  8.           <section allowdefinition="MachineToApplication" name="profileService" requirepermission="false" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  9.           <section allowdefinition="MachineToApplication" name="authenticationService" requirepermission="false" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">  
  10.                                    </section>  
  11.                               </section>  
  12.                          </section>  
  13.                     </sectiongroup>  
  14.                </section>  
  15.            </sectiongroup>  
  16.        </sectiongroup>  
  17. </configsections>  
Comment out the config section (or remove it if you like), and you are done. Good luck!