Email Aaron Blake now at webmaster@aaronblake.co.uk
or contact me

ASP.net AJAX in .net 2.0

ASP.net AJAX in .net 2.0

Introduction

This tutorial is a quick guide to get any ASP.net 2.0 sites running ASP.net AJAX extensions and controls, even if it hasn’t been installed on the host server. I won’t cover how to use the AJAX controls, because there is plenty of documentation out there on this already.

Requirements

  • Visual Studio 2005 or higher.
  • ASP.net AJAX Extensions installed on the development machine. http://www.asp.net/ajax/downloads/
  • The host server must have at least .net 2.0.

STEP 1 – Add AJAX Extensions to project

  • Create a new or open an existing website in Visual Studio.
  • Create a bin folder in the root of the project.
  • Copy the following files from C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025 , into the bin folder of your website:
    • System.Web.Extensions.dll
    • AJAXExtensionsToolbox.dll
    • System.Web.Extensions.Design.dll

(note – The location of the AJAX dlls may be in a different folder depending on your system setup. If you cant find them, then reinstall the extensions on to your machine.)

STEP 2 – Configure web.config

You need to make sure you add the following sections to your web config to get the extensions to work:

Assemblies Section

<system.web>
 <compilation>
   <assemblies>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0,
                   Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </assemblies>
 </compilation>
</system.web>

Pages Section

<system.web>
 <Pages>
  <Control>
   <add tagPrefix="asp" namespace="System.Web.UI"
      assembly="System.Web.Extensions, Version=1.0.61025.0,
                Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <Control>
 <Pages>
<system.web>

HttpHandlers

<system.web>
 <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"/s>
   <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>
</system.web>

System.WebServer

After the system.web element, add the following:

<system.webServer>

<modules>

<add name=ScriptModulepreCondition=integratedModetype=System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
/>

</modules>

<handlers>

<remove name=WebServiceHandlerFactory-Integrated/>

<add name=ScriptHandlerFactoryverb=*path=*.asmxpreCondition=integratedModetype=System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
/>

<add name=ScriptHandlerFactoryAppServicesverb=*path=*_AppService.axdpreCondition=integratedModetype=System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
/>

<add name=ScriptResourcepreCondition=integratedModeverb=GET,HEADpath=ScriptResource.axdtype=System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
/>

</handlers>

</system.webServer>

Conclusion

Your website should be now ASP.net AJAX ready.

For more information you can check out this good article here:

Bookmark and Share

2 Trackbacks

  1. [...] STEP 1 – ASP.net AJAX Extensions Before you can add the AJAX Control Toolkit to your site, you need to set it up to work with ASP.net AJAX. A guide to do this in .net 2.0 can be seen in the previous tutorial.  http://www.aaronblake.co.uk/blog/2009/05/14/aspnet-ajax-in-net-20/ [...]

  2. [...] STEP 1 – ASP.net AJAX Extensions Before you can add the AJAX Control Toolkit to your site, you need to set it up to work with ASP.net AJAX. A guide to do this in .net 2.0 can be seen in the previous tutorial.  http://www.aaronblake.co.uk/blog/2009/05/14/aspnet-ajax-in-net-20/ [...]

Post a Comment

You must be logged in to post a comment.

Email me through this magic form.