New Features in ASP.NET 4.0

Leverage the new features in ASP.NET 4.0 to build scalable, robust, high-performance web applications

aspFeature

New Features in ASP.NET 4.0

Leverage the new features in ASP.NET 4.0 to build scalable, robust, high-performance web applications

By Joydip Kanjilal

Microsoft's ASP.NET is one of the most successful web application development frameworks ever. Over the years, it has matured to become one of the best frameworks for developing highly scalable, high-performance web applications in a managed environment. ASP.NET 4.0, shipped as part of Visual Studio 2010, contains many new and interesting features. This article reviews these new features and enhancements in ASP.NET 4.0.

Prerequisites

To work with ASP.NET 4.0, you should have the following installed in your system:

         Visual Studio 2010 Beta 1 or later

         .NET Framework 4.0 (this actually ships as part of Visual Studio 2010)

Visual Studio 2010 is scheduled to be released in the first half of 2010. As of this writing, Visual Studio 2010 Beta 1 is available for a free download. You can download Visual Studio 2010 and .NET Framework 4 Beta 1 here.

What's New

Microsoft has added many new and enhanced features to ASP.NET in version 4.0. Here's a summary of the most important new features.

Enhanced State Management Features

ASP.NET 4.0 includes improved state management features. You now have much better control of ViewState by using the ViewStateMode property, which gives you better control of your ViewState. This property can have one of the three values: Enabled, Disabled, or Inherit.

Another new property is ClientIDMode, which you use to set the ClientID for Server Controls and using it from the client side. The ClientIDMode property can have one of the four values: Static, Predictable, Legacy, or Inherit. This property comes in handy, especially in situations where your control is embedded inside a parent control.

Performance Monitoring

ASP.NET 4.0 enables you to monitor resource functionality being used by the CLR. To do this, you need to use the following configuration in the aspnet.config file:

<configuration>

<runtime>

<appDomainResourceMonitoring enabled="true"/>

</runtime>

</configuration>

Enhancements to ListView Control

The LayoutTemplate for the ListView control has been made optional in ASP.NET 4.0. You can just use the ItemTemplate to display your data.

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"

ClientIDMode="Predictable">

<ItemTemplate>

Customer Code:

<asp:Label ID="lblCustomerCode" runat="server" Text='<%# Eval("CustomerCode") %>' />

<br />

Customer Name:

<asp:Label ID="lblCustomerName" runat="server" Text='<%# Eval("CustomerName") %>' />

<br />

</ItemTemplate>

</asp:ListView>

Extensible Output Caching

Output caching is a feature in ASP.NET that lets you cache the output of pages in memory so that subsequent requests to the same page can be fetched from the cache. This improves the application's performance to a considerable extent, particularly for web pages that contain relatively stale data. Extensible output caching can be used to add extensibility points to output caching and configure one or more custom output-cache providers. The cache API in ASP.NET 4.0 allows you to use the following cache storages:

         disk-based output caches

         custom object caches

         distributed object caches

         cloud-based object caches

Here is how you can configure your custom output cache provider in the web.config file:

<caching>

<outputCache defaultProvider="aspNETPROProvider">

<providers>

<add name="DiskCache"

type="aspNETPRO.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/>

</providers>

</outputCache>

</caching>

Search Engine Optimization

WebForm Routing enables you to access Web Forms with user-friendly and descriptive URLs for better search engine optimization (SEO). Note that the System.Web.Routing namespace provides support for routing through the RouteTable and PageRouteHandler classes. You can also achieve better SEO by using the Page Meta Keyword and Description feature in ASP.NET 4.0. Here's an example of how to use Page Meta Keyword and Descriptions programmatically:

protected void Page_Load(object sender, EventArgs e)

{

this.Page.Title = "Joydip Kanjilal's Technology Corner";

this.Page.MetaKeywords = "MVP";

this.Page.MetaDescription = "My Blog";

}

More ASP.NET 4.0 Resources

Following are a few links for further references on this topic. I also cover ASP.NET 4.0 features in more depth in my latest book, ASP.NET 4.0 Programming (McGraw-Hill Osborne Media), to be published later this year.

ASP.NET 4.0 and Visual Studio 2010 Web Development Beta 2 Overview

Stephen Walther - New Features of ASP.NET 4.0

Overview of .NET 4.0 features ASP.NET 4.0 ClientIDMode

New Features in ASP.Net 4.0 - PART 1

New Features in ASP.Net 4.0 - PART 2

Joydip Kanjilal ([email protected]) is a Microsoft MVP in ASP.NET. He has more than 12 years of industry experience in IT with more than six years in Microsoft .NET and its related technologies.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish