ajax and web.config

Discussion in 'ASP.NET 2.0' started by jb2006, Aug 20, 2007.

  1. Is there a kb article or other source that lists all the proper elements that must be added to web.config to use ajax on discountaspnet? What I've found to this point doesn't provide this.

    I did findexamples on asp.net. But when I added it to our site's web.config it caused errors. So I'm guessing there is a specific set up for discountaspnet.
    http://asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx

    Thanks in advance.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. It was some type of configuration error. I installed ajax 1.0 on my local computer so I could view the web.config provided with that installation. The problem was I left out the system.web.extensions elements.

    Here is the web.config example that comes with ajax 1.0 if anyone else comes across this:


    <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>
    <system.web>
    <pages>
    <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </controls>
    </pages>
    <!--
    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="false">
    <assemblies>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </assemblies>
    </compilation>
    <httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>
    </system.web>
    <system.web.extensions>
    <scripting>
    <webServices>
    <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
    <!--
    <jsonSerialization maxJsonLength="500">
    <converters>
    <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
    </converters>
    </jsonSerialization>
    -->
    <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
    <!--
    <authenticationService enabled="true" requireSSL = "true|false"/>
    -->
    <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
    and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
    writeAccessProperties attributes. -->
    <!--
    <profileService enabled="true"
    readAccessProperties="propertyname1,propertyname2"
    writeAccessProperties="propertyname1,propertyname2" />
    -->
    </webServices>
    <!--
    <scriptResourceHandler enableCompression="true" enableCaching="true" />
    -->
    </scripting>
    </system.web.extensions>
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
    <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
    <remove name="WebServiceHandlerFactory-Integrated" />
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
    type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
    type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.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=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
    </system.webServer>
    </configuration>
     
  4. One other thing I forgot to note. Make sure you place the configSections element above the appSettings element. Not sure why but it caused a runtime error when I had it below.
     

Share This Page