Zieglers

Just little about C#, .NET, SQL Server, SharePoint and SAP

Web.Config entries for enabling AJAX for SharePoint 2007

Posted by zieglers on February 2, 2009

   There are several steps to be followed when you want to enable AJAX for SharePoint 2007 such as installing Microsoft ASP.NET AJAX 1.0 and referencing AJAXControlToolkit.dll in your Visual Studio Web Part project. However, I think the most important part is providing required web.config entries. Most of the problems encountered during the process of enabling AJAX for SharePoint 2007 results from missing entries in web.config. That’s why I wanted to list them as follows:

 

Extending SharePoint web.config files with Microsoft ASP.NET AJAX 1.0

In order to enable and leverage ASP.NET AJAX capabilities for SharePoint 2007, some entries must be added to web.config file. 

 

1. Add a <sectionGroup> element to the <configSections> tag:

 

<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>   

 

2. Add a <controls> section as a child of the <system.web>/<pages> tag.

 

    <pages>
      <controls>
        <add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
      </controls>
   
</pages>   


3. Add the following tag to the <assemblies> tag, within <compilation>:


      <assemblies>
       <add assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
     
</assemblies>


4. Add some new registrations to the end of the <httpHandlers> section:


 <httpHandlers>
      <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>

 

5. Add a new registration to the HttpModules section, beneath any existing registrations.


  <httpModules>
      <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
  </httpModules>


 

6. Add a SafeControl entry for the System.Web.UI namespace from Microsoft Ajax Extensions, within the <SharePoint>/<SafeControls>section:


  <SafeControls>
      <SafeControl Assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Web.UI” TypeName=”*” Safe=”True” />
  </SafeControls>

 

7. Finally, add the following configuration tags at the bottom of web.config, near the bottom before the end <configuration> tag.


  <system.web.extensions>
    <scripting>
      <webServices>
      <!– 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>

 

Adding a ScriptManager into a SharePoint MasterPage

 

Add the following into the markup of your master page.  A recommended location is right beneath the WebPartManager registration (search for  <WebPartPages:SPWebPartManager id=”m” runat=”Server” />):

    <asp:ScriptManager runat=”server” ID=”ScriptManager1″></asp:ScriptManager>

 

zieglers

 

Advertisements

2 Responses to “Web.Config entries for enabling AJAX for SharePoint 2007”

  1. […] Web.Config entries for enabling AJAX for SharePoint 2007 […]

  2. Ravi Kore said

    Hi ,

    I have done all the settings mentioned above but i m not mentioning the scriptmanager in master page as we want script manager to be in user control where we are using the ajax control. when we deploy this user control on SP server it giving the error “extender controls may not be registered before prerender” . Please help what could be done some extra so that it will run on SP2007 server.

    Thanks,
    Ravi Kore

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: