8159 Views // 0 Comments // Not Rated

Using ASP.NET AJAX 3.5 JSON Web Services In SharePoint 2007

I've been writing a lot lately about getting SharePoint 2007 operating in the latest-and-greatest environments, and using the latest-and-greatest technology to build its content. With this post, this will all come to fruition, as I add JSON Web Services to the mix. As it stands, in terms of my previous posts, (which make for excellent bathroom reading) here's where we're at:

  • SharePoint 2007 Service Pack 1
  • Windows Server 2008
  • ASP.NET 3.5
  • IIS 6.0
  • AJAX Control Toolkit 3.5

The only thing missing is JSON Web Services. I have written extensively about these babies in two parts (here and here). When I started adding this technology to my web parts, I was happy to see that I had to do relatively little work to get them up and running.

A lot of this is due to SP1 of SharePoint 2007 and ASP.NET 3.5 both promoting AJAX to being a first class citizen. This has really allowed me to spend much more time playing with AJAX and much less time configuring SharePoint to make it work.

So read those links on how to build the necessary components to be able to use JSON Web Services in your user controls (which will be hosted in SmartParts on your SharePoint site). The "final" step, deployment to SharePoint, is so easy that I can describe it in a bulleted list:

  • Add the following line to your web app's web.config file, in the <httpHandlers> section (everything else should be there, if you're up to ASP.NET 3.5)

    Code Listing 1

    1. /><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  • Copy your user control (.ASCX and .CS/.VB) to the UserControls folder under your web app.  GAC or BIN your assembly.
  • Copy your JavaScript and Web Service (.asmx only) files to the same folder, or wherever you have them referenced (by default, the folder ending in the port number is the root (/) relative path).

And that's it! You don't have to stray from the WSS_Minimal trust setting in the web.config, you don't have to remove ASMX from the blocked file types, and you don't have to worry about any permission problems common to SharePoint. ASP.NET AJAX 3.5 takes care of everything! Actually, the only thing I had to change in my code was in the code-behind of my control, when I wire up the scripts and services to the Script Manager: I had to preceded the relative URL with a forward slash. That's it! Have fun!

4 Tags

No Files

No Thoughts

Your Thoughts?

You need to login with Twitter to share a Thought on this post.