Tuesday 4 May 2010

Features new to ASP.Net 4

As usual this is not intended to be  a comprehensive list but an aide-mémoire

See http://msdn.microsoft.com/en-us/library/s57a598e.aspx

Extensible output caching

Output caching now enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism (e.g. disk, cloud storage, and distributed cache engines).

By default all HTTP responses, rendered pages, and controls use the in-memory output cache (the AspNetInternalProvider). You can change the default output-cache provider by specifying a different provider name for defaultProvider attribute (web.config).

In addition, you can select different output-cache providers for individual control and for individual requests and programmatically specify which provider to use.

<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>

Preloading web applications

A new application preload manager (autostart feature) is available when ASP.NET 4 runs on IIS 7.5 on Windows Server 2008 R2.

The autostart feature lets you perform expensive application initialisation prior to processing the first HTTP request (e.g. initialise an application and then signal a load-balancer that the application was initialised and ready to accept HTTP traffic).

This feature requires modification of the IIS 7.5 applicationHost.config. You can implement System.Web.Hosting.IProcessHostPreloadClient within your application which will be invoked by the autostart feature.

“When an IIS 7.5 server is cold-started or when an individual application pool is recycled, IIS 7.5 uses the information in the applicationHost.config file to determine which Web applications have to be automatically started. For each application that is marked for preload, IIS7.5 sends a request to ASP.NET 4 to start the application in a state during which the application temporarily does not accept HTTP requests. When it is in this state, ASP.NET instantiates the type defined by the serviceAutoStartProvider attribute (as shown in the previous example) and calls into its public entry point.”

Permanent page redirection (HTTP 301)

ASP.NET 4 adds a RedirectPermanent helper method that makes it easy to issue HTTP 301 (Moved Permanently) responses:

RedirectPermanent("/newpath/foroldcontent.aspx");

Session state compression

ASP.NET 4 introduces a new compression option for out-of-process session state providers (including using SQL Server).

“You can set this option using the new compressionEnabled attribute of the sessionState element in the configuration file. When the compressionEnabled configuration option is set to true, ASP.NET compresses (and decompresses) serialized session state by using the .NET Framework GZipStream class.”

ASP.Net web forms

New features include:

  • The ability to set meta tags.
    • Two properties have been added to the Page class: MetaKeywords and MetaDescription.
  • More control over view state.
    • A new property has been added to the Control class: ViewStateMode. You can use this property to disable view state for all controls on a page except those for which you explicitly enable view state.
  • Support for recently introduced browsers and devices.
    • Browser capabilities are represented by the HttpBrowserCapabilities object which is stored in the HttpRequest.Browser property.
    • Browser definition files have been updated to contain information about recently introduced browsers and devices.
  • Easier ways to work with browser capabilities.
    • You can now write a custom provider to determine browser capabilities (e.g. accessing a database or web service).
  • Support for using ASP.NET routing with Web Forms.
    • Pinched from MVC and now in ASP.Net.
  • More control over generated IDs.
    • Huzzah!
    • http://msdn.microsoft.com/en-us/library/1d04y8ss.aspx
    • ClientID now has 4 ClientIDModes:
      • AutoID – the old way.
      • Static – set it yourself but risk having multiple controls with the same ID on a page.
      • Predictable – a bit of a half-way house; use for data binding.
      • Inherit – the mode is inherited from the page or parent control.
  • The ability to persist selected rows in data controls.
  • More control over rendered HTML in the FormView and ListView controls.
  • Filtering support for data source controls.
    • QueryExtender control can be added to EntityDataSource or LinqDataSource controls in order to filter the data returned by these controls.
  • Enhanced support for Web standards and accessibility. There’s a stack of these including:
    • CSS for controls that can be disabled (disabled="disabled" no longer added to display-only controls such as labels; class="aspNetDisabled" used instead).
    • CSS for validation controls - ASP.NET 4 does not automatically show error messages in red.
    • CSS for the hidden fields Div element
    • CSS for the Table, Image, and ImageButton Controls
    • CSS for the UpdatePanel and UpdateProgress Controls
    • Eliminating Unnecessary Outer Table
    • Layout Templates for Wizard Controls
    • New HTML Formatting Options for the CheckBoxList and RadioButtonList Controls
    • Header and Footer Elements for the Table Control
    • CSS and ARIA Support for the Menu Control
    • Valid XHTML for the HtmlForm Control
    • Maintaining Backward Compatibility in Control Rendering
  • ASP.Net MVC – actually this is in the box with Visual Studio 2010, not the .Net framework or ASP.Net.
  • Dynamic Data
    • Enabling Dynamic Data for Individual Data-Bound Controls in Existing Web Applications
    • New Field Templates for URLs and E-mail Addresses
    • Creating Links with the DynamicHyperLink Control
    • Support for Inheritance in the Data Model
    • Support for Many-to-Many Relationships (Entity Framework Only)
    • New Attributes to Control Display and Support Enumerations
    • Enhanced Support for Filters
  • ASP.Net Chart Control
    • Data series, chart areas, axes, legends, labels, titles, and more.
    • Data binding.
    • Data manipulation, such as copying, splitting, merging, alignment, grouping, sorting, searching, and filtering.
    • Statistical formulas and financial formulas.
    • Advanced chart appearance, such as 3-D, anti-aliasing, lighting, and perspective.
    • Events and customizations.
    • Interactivity and Microsoft Ajax.
    • Support for the Ajax Content Delivery Network (CDN), which provides an optimized way for you to add Microsoft Ajax Library and jQuery scripts to your Web applications

Also of interest

Web application deployment with Visual Studio 2010 - http://msdn.microsoft.com/en-us/library/bb386521.aspx

Enhancements to ASP.NET Multi-Targeting