Tuesday, February 19, 2013

ASP.NET 4.5 features make upgrade worth the trouble

Microsoft continues to add new features and fix others in ASP.NET, while I continue to support an ASP.NET 1.1 application along with many others using the various flavors of ASP.NET. The latest version to hit the streets (ASP.NET 4.5) coincides with the release of .NET Framework 4.5. It was released late last year, but I am just now diving in to it as I begin development on an application for a new client. Here's a quick tour of ASP.NET 4.5; I'll focus on specific features in future posts.

Version confusion

The 4.5 version number deserves discussing for the pure fact that it is a little confusing. Microsoft has been releasing technologies (via CodePlex) even before .NET Framework 4.5 was released; for this reason, the version numbers for the various technologies within the framework are out of sync.

Microsoft incremented the base framework and ASP.NET a half point (4 to 4.5), while core languages received a full increase with C# 5.0 and Visual Basic 11. Past upgrades have allowed you to utilize multiple versions side-by-side, but this is tricky, as the .NET Framework 4.5 installation replaces libraries used in 4.0 applications.

In short, be careful with the upgrade. I am in such a situation, so I will discuss this in more detail in the future.

Where do we begin?

There are too many features in ASP.NET 4.5 to cover in one post, so I'll stick with some of the notable features added or enhanced in this version.

  • Web Sockets: Full support for the Web Sockets HTML5 standard is available with ASP.NET 4.5 running on IIS 8.0 via the SignalR library. This allows you to easily add real-time Web functionality to applications.
  • Authentication: There is now a universal provider (DefaultMembershipProvider) for simplification. In addition, the OAuth protocol is embraced.
  • Async programming: While this feature is not ASP.NET-specific, it is worth noting that C# 5 and Visual Basic 11 provide async support without using multiple threads (via async and await keywords).
  • Web publishing: This feature has been enhanced, whereas you can compare local and remotes files, publish only selected files, and so forth.
  • Web API: This API provides the REST approach to building applications — a key difference from the WCF alternative. In addition, the Web API now includes extensive OData support, which is another instance of Microsoft embracing open source standards.
  • Friendly URLs: The popularity of tinyurl demonstrates the widespread problem of keeping up with long, arcane URLs. This feature is now available with ASP.NET applications via theFriendlyURLs feature.
  • Mobile: The explosion of smartphones, eReaders and other mobile devices has changed the landscape for Web application development. HTML5 support is supposed to simplify mobile application development. In addition, MVC 4 includes mobile templates, and there are a variety of mobile device emulators that can be used in Visual Studio 2012.
  • IIS: This allows you to use new features available in Internet Information Server (IIS) 8.0. Some of these features include prefetching and application initialization like application ping on startup. Also, an express edition of IIS is now available.

Web Forms

Once upon a time I thought Web Forms may be on their way out, but ASP.NET 4.5 proves me wrong with many updates to the stalwart of ASP.NET interface design. These enhancements are one of the reasons I was intrigued by the newest release of ASP.NET.

While MVC developers are fully aware of model binding, it is now available to the Web Forms world. Model binding binds a value in the client application to a model on the server — this allows validation on the server. In addition to model binding, ASP.NET 4.5 offers strongly typed. A new ModelType property has been added to the data controls that allows you to specify the type of object that is bound to the control. The IQueryable object allows you to manipulate the query to provide paging, sorting, and much more. Web Forms also adds HTML5 support.

ASP.NET 4.5 includes a feature called unobtrusive validation that allows you to configure validator controls to use unobtrusive JavaScript for client-side validation logic. The net result is a large reduction in the amount of JavaScript rendered inline in the page markup. If you prefer an alternative, ASP.NET MVC 4 and Web Pages 2 are available.

Open source

This may be showing my age, but I am still surprised at how .NET has embraced open source in so many ways. The robust support for HTML5 and JavaScript (including jQuery libraries) in building ASP.NET and Windows 8 applications is a great example. I was skeptical when the CodePlex site first arrived, but it has proved to be a great vehicle for pushing new projects (as well as for providing Microsoft with an outlet to release technology updates). A good example of such a project is JSON.NET. The future seems bright for open source and .NET.

Too much for one person

I will pick certain ASP.NET 4.5 features as we build a new application, but I will use older methods for some features. The days of one developer keeping up with all facets of the .NET Framework and ASP.NET are over — the technology and products is overwhelming. This is why you have some developers who stick with Web Forms (my hand is raised), others who jump on the MVC train, and still others use both or alternatives.

The complexity of the .NET technologies overwhelmed me in the past, but I now realize it is a great situation because it provides flexibility and options when building an application; this fosters the creativity that so many developers love and crave.

ITWORLD
If you have any question then you put your question as comments.

Put your suggestions as comments