ASP.NET 4.0 is very different from its “out-of-the-box” forebears. Microsoft has transitioned away from Windows-oriented programming to promote more contemporary Web development standards, experts say.
“I think the changes in ASP.NET can be summed up in these proverbial four words: close to the metal,” said Andrew Brust, a Microsoft regional director (recognized by Microsoft for technical expertise) and chief of new technology at twentysix New York. Microsoft is allowing developers to cut through its forms package abstraction layer, he explained.
“Whether it’s URL routing, programmatic control of meta-keywords and description content, better control over view state or over server control-generated client IDs, Web Forms becomes much less of a black box and much more something that provides fine-grained control for those who want it,” Brust said.
URL routing adds search-engine optimization value to WebForms, said Chris Bannon, ASP.NET product manager at ComponentOne. “It’s easy to use, especially if you are familiar with MVC.”
View state is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks, according to Microsoft. The change to view state, while subtle, cannot be overlooked, said Todd Anglin, chief evangelist at Telerik. Its model is now “opt out” rather than “opt in,” creating an easy way for developers to take advantage of view state.
Microsoft also added compression for session state using Gzip (GNU zip). AJAX compression produced a radical reduction in response times in Infragistics’ ASP.NET AJAX controls, said Andrew Flick, product manager for Win Client at Infragistics.
Other time-savers are focused on developer productivity. User-generated control IDs eliminate the challenge of trying to find unpredictable control IDs, said Bannon. A control ID uniquely identifies ASP.NET server controls, thus enabling them to be programmatically accessed in the code-behind class, according to Microsoft.
“It’s easier to write jQuery against IDs that you know without having to wait until they render to know what they are,” Bannon said. It is easier for a developer to remember what a control does if he or she knows the name of the control, he explained. Microsoft is also giving developers more control over client-side scripting.
By supporting jQuery, Microsoft is encouraging its developers to directly write client-side scripts in order to implement AJAX features in their applications, rather than relying on server controls to emit that script, said Brust. Microsoft’s embrace of jQuery has been wholehearted, both in technology and in terms of product team enthusiasm, he added.
However, the productivity offered by the templates in the near term may be outweighed by the long-term impact of Microsoft’s technology shift to jQuery. Organizations that are starting to adopt ASP.NET should pause before using Microsoft’s AJAX templates, because Microsoft will no longer be enhancing or investing in those, Anglin noted. The existing Microsoft AJAX library is available under an open-source license.
However, Microsoft’s new site template in Visual Studio 2010, which follows the company’s prescriptive guidance for building WebForms applications, includes references to jQuery, Bannon said. The template is one of the quickest ways to get started with an ASP.NET product, he said.
Some of the benefits of using jQuery are that it allows developers to write “true” AJAX code, said Bannon. “jQuery lets you write code against markup and not worry about cross-browser compatibility. You don’t spend 90% of your time debugging as you previously had to [with Microsoft’s AJAX library].”
Telerik has been adopting jQuery internally for its RadControls for ASP.NET, Anglin said. The result has been controls that have a smaller footprint, simpler APIs and more richness, he added.
A small part of its motivation was to progressively win over some of the “traditionally anti-Microsoft crowd” by adopting a popular open-source library, Anglin added. “It’s not likely enough to see converts in droves, but it will give many open-sourcers reason to pause and realize how Microsoft has changed.”
SUBHED: Coming of age
Similarly, Microsoft’s strategy with its MVC framework is to pull PHP and Ruby developers into the ASP.NET world of doing things, where application front ends are lightweight and responsive, Infragistics’ Flick said.
ASP.NET MVC 2 enables developers to build more modular, reusable applications, said Mark Dunn, a regional director and president of DUNN Training and Consulting. The MVC pattern separates business logic from presentation logic as well as providing a clear distinction between client and server code.
“ASP.NET MVC now has a prominence in the .NET stack that is at least equal to that of ASP.NET Web Forms. ASP.NET MVC was introduced almost as a skunk works project—a kind of interesting curiosity—and yet it now seems to be entrenched and fully part of the .NET Web development orbit,” Brust said.
Microsoft’s ASP.NET Dynamic Data framework has also come of age. Dynamic Data enables developers to build data-driven websites that work against the ADO.NET Entity Framework or LINQ to SQL. ASP.NET 4 extends the framework to any application; its use was previously limited to Dynamic Data projects, Bannon said.
Consequently, any developer can integrate Dynamic Data into his or her ASP.NET data control with just one line of code, Bannon explained. Dynamic Data adds rich views and editors to controls. ComponentOne is using Dynamic Data in its GridView ASP.NET grid control for field and type validation.
“Tons of people are using data controls. If they take time and call this one line of code, they can enhance UI and validation in their application,” Bannon said. “The major benefits of DynamicData are strongly typed UI elements, built-in data validation, template-driven views/editors, and it is entirely driven by metadata. Dynamic Data is my new favorite feature in ASP.NET 4.0, and leveraging it in existing apps can enhance your UI and data integrity.”
ASP.NET also provides developers with broader options for caching, reducing memory requirements and increasing application scalability. Microsoft’s hard-coded caching model, which only utilizes server memory, has been replaced with a provider-based model. The new model allows developers to substitute ASP.NET’s built-in providers with their own solutions or solutions from third-party vendors, Telerik’s Anglin said.
Using disk-based caching is slower but consumes less memory, he said. “It’s good for things that are not accessed often.” Developers may also use Microsoft’s AppFabric distributed caching solution to scale their applications as the demand for them increases, he added. “Applications will not hit limits as they become more popular or need to be adapted to new programming styles.”
twentysix New York’s Brust added that direct control of the emitted page’s content is what many developers want, regardless of platform, and now ASP.NET developers, whether they use MVC or Web Forms, have that control.
“Developers who have worked heavily with .NET 1.x and 2.0 may find this shift awkward, even regressive,” he said. “I would encourage them to open their minds to it and rethink the way they code and architect their applications to accommodate the change. That will help them be in sync with contemporary Web development standards across all platforms.”