Friday, October 10, 2008 8:17 AM Jan Tielens

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.
Filed under:

Comments

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

Friday, October 10, 2008 1:08 PM by MOSSLover

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.

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

Monday, October 13, 2008 12:17 PM by Tobias Zimmergren

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.

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

Wednesday, October 15, 2008 5:31 PM by Ha!

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

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

Thursday, October 16, 2008 12:58 PM by Tom

WOW! Thank you SO MUCH! This was the only thing that worked for me. I tried to do it manually but failed. Thanks so much!!!!!!!

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

Wednesday, October 22, 2008 8:28 AM by vamsy krishna

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

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

Wednesday, October 22, 2008 6:38 PM by Peter Schwartz

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

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

Thursday, December 4, 2008 5:09 PM by Adam

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.

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

Tuesday, December 16, 2008 10:49 AM by Agust

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?