Friday, June 19, 2009

ASP.NET AJAX in .NET 3.5 and VS 2008

In the past I've blogged about the JavaScript and AJAX improvements with VS 2008 JavaScript Intellisense and VS 2008 JavaScript debugging. Below are a few notes about some of the ASP.NET AJAX runtime features coming as part of the VS 2008 and .NET 3.5 release, as well as important notes to read if you are opening existing ASP.NET AJAX 1.0 projects in VS 2008.

ASP.NET AJAX included in .NET 3.5

ASP.NET AJAX 1.0 shipped as a separate download that you could install on top of ASP.NET 2.0. Starting with the .NET Framework 3.5 release, all of these features are built-in with ASP.NET, which means you no longer have to download and install a separate ASP.NET AJAX setup when building or deploying applications.

When you create a new ASP.NET application or web-site in VS 2008 that targets the .NET 3.5 framework, VS will automatically add the appropriate AJAX registrations in your web.config file and the core ASP.NET AJAX server controls will show up in your toolbox.

The version of ASP.NET AJAX that ships with .NET 3.5 has a number of nice improvements to it - including support for using UpdatePanels with WebParts, support for WCF based JSON end-points, support for using the ASP.NET Profile, Role and Login Application Services using JavaScript, and a number of bug fixes and performance improvements.

Understanding ASP.NET AJAX Versioning

ASP.NET AJAX 1.0 and .NET 3.5 can both be installed side-by-side on the same machine. ASP.NET AJAX 1.0 is implemented in V1.0 of the System.Web.Extensions.dll assembly. The implementation of ASP.NET AJAX included with .NET 3.5 lives in V3.5 of the System.Web.Extensions.dll assembly. The V3.5 of System.Web.Extensions.dll is a fully compatible super-set of the 1.0 implementation (which means you don't need to change any code in order to use it).

Each ASP.NET application on a machine can choose which version of ASP.NET AJAX they want to build and run against. This is configured via the section in its web.config file, as well as by what System.Web.Extensions.dll assembly it is compiled against (with web-site projects these references are registered in the section of the web.config file, with web application projects they are referenced via the project file).

You will be able to use VS 2008 to target ASP.NET AJAX 3.5 applications, as well as to use the new VS 2008 multi-targeting support to build ASP.NET 2.0 applications that use ASP.NET AJAX 1.0. I cover how to-do both in the sections below.

Important Beta 2 Information

A few days before we shipped Beta2 on the web, we discovered a side-by-side issue with ASP.NET AJAX. If you read my original VS 2008 and .NET 3.5 Beta Released blog post, you'll remember that I called out this post-install patch step to fix this issue:

You should download and run this batch file. This takes only a few seconds to run, and fixes an issue we found earlier this week with the version policy of System.Web.Extensions.dll - which is the assembly that contains ASP.NET AJAX. If you don't run this batch file, then existing ASP.NET 2.0 projects built with ASP.NET AJAX 1.0 and VS 2005 will end up automatically picking up the new version of ASP.NET AJAX that ships in .NET 3.5 Beta2. This will work and run fine - but cause you to inadvertently introduce a .NET 3.5 dependency in the applications you build with VS 2005. Running the batch file will change the version binding policy of the new System.Web.Extensions.dll assembly and ensure that you only use the new .NET 3.5 ASP.NET AJAX version with projects that you are explicitly building for .NET 3.5.

The good news is that this fixes the side-by-side issue we found, and makes it safe to develop ASP.NET AJAX with both VS 2005 and VS 2008 on the same machine.

The one gotcha is that it causes VS 2008 to incorrectly detect the version of ASP.NET AJAX being used when first opening older ASP.NET 2.0 projects (specifically it can cause VS 2008 to think the project is already using .NET 3.5). This requires that you to take a few additional steps in Beta2 the first time you open existing ASP.NET AJAX 1.0 web-site projects with VS 2008 to correct this. You will not need to take these steps with the final VS 2008 release.

See full detail:

No comments: