Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [12]

By Root 5645 0
tools. You had to choose the tool beforehand and adapt to its vision of the Web. Today with AJAX, we are experiencing something similar. You have an AJAX API in ASP.NET Web Forms based on a technology known as partial rendering; you have the possibility of defining ASP.NET endpoints and exposing them as Web services; you have similar technologies in ASP.NET MVC; you have direct scripting via jQuery and a bunch of other JavaScript libraries. We don’t have yet a unique (and updated) model for doing Web development with AJAX in it. AJAX changed the Web; now we want a framework for writing Web applications with AJAX built inside.

Selective Updates


Basically, there are two ways in which you can incorporate AJAX into a Web framework. I like to refer to them as selective updates and direct scripting.

You perform a selective update when you execute a server action and then return a chunk of HTML to selectively update the current view. This approach descends from the HTML Message AJAX pattern as summarized at http://ajaxpatterns.org. The trick is all in bypassing the browser when a request—form post or hyperlink—has to be submitted. You place a script interceptor at the DOM level (for example, a handler for the Form DOM object submit event), capture the ongoing request, cancel the operation, and replace it with your own asynchronous implementation. When a response is received, it is assumed to be HTML and integrated into the current DOM at a given location.

An ASP.NET framework that fully supports the Selective Update model will specify details for how the script interceptor has to be defined and for how the current view has to be modified. In ASP.NET Web Forms, the Selective Update model is implemented via partial rendering. In ASP.NET MVC, it comes through the services of the AJAX HTML helper.

Direct Scripting


Direct scripting is plain JavaScript code through which you connect to a remote endpoint to send and receive data. You likely rely on a rich JavaScript framework (for example, jQuery) and use the JSON format to move complex data around.

In my opinion, the Direct Scripting model is good for little things that can improve a feature of the user interface. I don’t see the Direct Scripting model growing to become the reference pattern for AJAX applications. To be effective, direct scripting requires an ad hoc architecture and a new set of standards. Rich Internet Application (RIA) services and open protocols such as Open Data (oData) and Open Authorization (oAuth) are coming out, but direct scripting remains an option for a subset of sites and applications.

I wouldn’t pick up direct scripting as the solution for a unified programming model that accommodates the server-side Web and the client-side Web. Why not? With direct scripting, you are indissolubly bound to JavaScript and HTML. This is certainly great for some applications, but not for all.

To achieve direct scripting capabilities, today you have to look in the direction of the jQuery library and its plug-ins. I’ll cover jQuery in Chapter 21.

ASP.NET of the Future


ASP.NET 4 is the latest release of the ASP.NET framework that has seen the light in the same timeframe as Visual Studio 2010. As expected, ASP.NET 4 comes with a number of improvements mostly in the area of controlling the markup served by controls. You also find in ASP.NET 4 a richer caching API, routing support, further extensions of the provider model, and a few new server controls.

If you try to weigh out the new features in the framework, you probably find enough to justify a new release, but not necessarily a fundamental release in the history of the product. Why is this so?

As mentioned, ASP.NET as we’ve known it for a decade is really approaching an architectural dead end. There’s not much else that can be added to the Web Forms model; likewise, there are a few aspects of it that sound a bit obsolete today, but changing them would require a significant redesign of the system. From here, the following question arises: What will be the ASP.NET of the future?

Will it be just a further

Return Main Page Previous Page Next Page

®Online Book Reader