Enabling .NET 3.5 in SharePoint 2007 Sites, the Lazy Way

You probably know that if you want to make use of the fancy new .NET stuff, like ASP.NET AJAX in SharePoint 2007 sites, you have to make a bunch of modifications in the web.config of that site. You can do that the manual way, for example Mike Ammerlaan has described how you can enable ASP.NET AJAX 1.0 in SharePoint sites already a long time ago. Recently .NET 3.5 (including a new version of ASP.NET AJAX) became available, including the steps that you needed to go through to be able to enable it in SharePoint sites. You can check out Tobias Zimmergren’s post for example to get an idea.

Of course the manual approaches work, but it’s quite a lot of XML that you have to copy-and-past into the SharePoint web.config files. If you prefer an automated way to apply those changes, you can check out the SharePoint 2007 Features project on CodePlex. Over there you can find some feature that will apply the changes for you. But before you get too excited; make sure you test those features in your farms, because I’ve had some nasty experiences deploying them in SharePoint farms with multiple front-end web servers.

Today I’d like to introduce you the lazy way to apply the necessary changes for enabling .NET 3.5 (including the corresponding version of ASP.NET AJAX) in SharePoint 2007 sites. Actually it’s my lazy U2U colleague Lieven Iliano who thought me the trick, and I’ve been using it ever since in my classes and demos. The trick is to slightly abuse Visual Studio 2008 (just a little bit) here are the steps:

  • Start Visual Studio 2008.
  • Create a new dummy ASP.NET Web Application Project, and make sure you target the .NET Framework 2.0 (upper right dropdown of the New Project dialog). The name of this project is not important; you won’t need it anymore when we’re done.
  • Copy the web.config of your SharePoint 2007 site, into the dummy Web Application project in Visual Studio.
  • Open the Project Properties in Visual Studio (right click on the Project node in the Solution Explorer, and choose Properties; or in the Project menu, select WebApplicationX Properties).
  • Select .NET Framework 3.5 in the Target Framework dropdown (select Yes in the confirmation dialog).
  • Copy the web.config from the Web Application Project back to SharePoint.
That’s it; you now have copied the upgraded web.config to the SharePoint site! At this moment you’re ready to make use of all the fancy new .NET 3.5 stuff in your SharePoint 2007 site.

7 Comments

  • If you create an AJAX App in .Net 3.5 you are still missing one key item. I did this wrong the other day. They need the safe control for they System.Web.Extensions. You can follow Mike Amerlaan's link above and just change the assembly number to 3.5.0.0, rather than 1.(and a bunch of numbers). It is the best way to it, because he breaks it down so well.

  • Hey Jan,
    I've had some issues with the Features project myself, but it's possible to get it working with some tweaking :-)

    I like the lazy-approach with VS 2008. Good one.

  • What a joke. This doesn't work. SharePoint and Ajax just weren't meant to be...

  • I want to know sharepoint..If u have any material please send to my mail id...........

  • Ha! What a joke. You were not meant to be...

  • One nice thing that this helped solve was errors writing .NET 3.5 code in application pages. The compiler needs to be changed to v3.5 (which this method handles automatically) when using .NET 3.5 in application pages because they are dynamically compiled. Otherwise, it won't know how to interpret things like linq queries.

  • Hello, I like the lazy approach - but I got this when I tried it to modify my web.config:
    "Only one instance of a ScriptManager can be added to the page"
    Any body have a hint why this happens? Could it be that somebody has messed with the master page of my server and added a script manager?

Comments have been disabled for this content.