Home > AJAX, ASP.NET, ASP.NET 4.0, ASPNET AJAX > First Look : ASP.NET 4 Beta 2 and Ajax Preview 4.0

First Look : ASP.NET 4 Beta 2 and Ajax Preview 4.0

I have just finished reading this white paper. I haven’t tried most of the things; but I wish to list some features which attracted me.

I can see extensive changes in AJAX but apart from that there are some remarkable changes that would give us more control by letting us extend them. As Dino Esposito says changes in ASP.NET 4.0 can be tagged as “More Control”.

The features I like in ASP.NET 4.0 Beta 2:

Core Services

Auto-Start web application:

A new scalability feature named auto-start that directly addresses this scenario is available when ASP.NET 4 runs on IIS 7.5 on Windows Server 2008 R2. The auto-start feature provides a controlled approach for starting up an application pool, initializing an ASP.NET application, and then accepting HTTP requests.

Permanently redirecting a page:

ASP.NET 4 adds a new RedirectPermanent helper method that makes it easy to issue HTTP 301 Moved Permanently responses rather than issuing HTTP 302 Found (Temporarily redirected) response which requires another round trip to the server.

Expanding the range of allowable URLs:

length of URL is no more limited to 260 and can customize the set of valid characters using the new requestPathInvalidChars attribute of the httpRuntime configuration element

Compress Session State:

When the compressionEnabled configuration option shown in the following example is set to true, ASP.NET will compress (and decompress) serialized session state by using the .NET Framework System.IO.Compression.GZipStream class. This is available only when out-of-process session is used.

Do you know it is possible to compress for in-proc session storage scenario also – even in ASP.NET 2.0?

Object Caching and Extensibility:

To make caching available for all applications, the .NET Framework 4 introduces a new assembly, a new namespace, some base types, and a concrete caching implementation.  The new System.Runtime.Caching.dll assembly contains a new caching API in the System.Runtime.Caching namespace.  The namespace contains two core sets of classes:
•    Abstract types that provide the foundation for building any type of custom cache implementation.
•    A concrete in-memory object cache implementation (the System.Runtime.Caching.MemoryCache class).

Extensible request validation:

The request validation feature has been made extensible so that we can use custom request-validation logic.(ASP.NET request validation searches incoming HTTP request data for strings that are commonly used in cross-site scripting (XSS) attacks)


Client Template rendering:

Templates offer the most manageable way of creating UI from data.

The following example shows a typical client template that we can create using ASP.NET AJAX 4.
<ul id="myTemplate" class="sys-template"
        <h3>{{ Name }}</h3>
        <div>{{ Description }}</div>


Data binding

One way live binding is what we saw in previous example {{ Description }}.

Two way live binding is useful when a text box is provided that enables users to modify the value of underlying data, as in the following example:
<input type="text" value="{binding Name}"/>

In two-way live binding, the binding works in both directions. If the target value is changed (in this case, the value in the UI), the source value is automatically updated (in this case, the underlying data item). Similarly, if the source value is changed (in this case, if the underlying data value is updated externally), the target value (the value in the UI) is updated in response. As a result, target and source are always in sync.

Observer Pattern

The observer pattern enables an object to be notified about changes that occur in another object. (The term observer pattern is often misused in JavaScript frameworks to describe event handling based on the addHandler method and similar techniques.) ASP.NET AJAX 4 implements the pattern completely. It adds observer functionality to ordinary JavaScript objects or arrays so that they raise change notifications when they are modified through the Sys.Observer interface

Client side controls

The DataView control can bind to any JavaScript object or array, or to any ASP.NET AJAX component

An example:

<ul sys:attach="dataview" class="sys-template"
    dataview:data="{{ imagesArray }}"
        <h3>{{ Name }}</h3>
        <div>{{ Description }}</div>

End-to-end Ajax-based data scenarios:

The AdoNetServiceProxy class enables read-write interaction with ADO.NET Data Services from JavaScript. The class enables access from JavaScript to a broad range of features of ADO.NET Data Services.

The AdoNetServiceProxy class is used by the AdoNetDataContext class in read-write scenarios that provides full support for change tracking in the browser. This enables complete end-to-end AJAX-based data scenarios.

The following example shows how to use the DataContext class.

<script type="text/javascript">
    var dataContext = new Sys.Data.DataContext();

<button onclick="dataContext.saveChanges()" class="right">Save Changes</button>

<ul sys:attach="dataview" class="sys-template"
    dataview:dataprovider="{{ dataContext }}"
        <input type="text" value="{binding Name}"/><br/>
        <input type="text" value="{binding Description}"/>

Web Form

View state enable/disable for individual controls:

All server controls have EnableViewState property including page. But one must remember that EnableViewState property is ignored for child controls. For example if Page has EnableViewState set to True,  its child control TextBox control will always read and write to the session state no matter what we set for enableviewstate property for that control.

But ASP.NET 4.0 will change this behavior by using a special property named ViewStateMode that accepts 3 values: enabled|disabled|inherit.

This is a good improvement.

Browser capabilities:

ASP.NET 4 includes a feature referred to as browser capabilities providers. As the name suggests, this lets us build a provider that in turn lets us to use our own code to determine browser capabilities.


ASP.NET 4 adds built-in support for using routing with Web Forms. Routing lets us configure an application to accept request URLs that do not map to physical files. Instead, we can use routing to define URLs that are meaningful to users and that can help with search-engine optimization (SEO) for our application. For example, the URL for a page that displays product categories in an existing application might look like the following example:
By using routing, we can configure the application to accept the following URL to render the same information:

Client ID creation

The new ClientIDMode property addresses a long-standing issue in ASP.NET, namely how controls create the id attribute for elements that they render.

The new ClientIDMode property lets you specify more precisely how the client ID is generated for controls. You can set the ClientIDMode property for any control, including for the page. Possible settings are the following:
•    AutoID – This is equivalent to the algorithm for generating ClientID property values that was used in earlier versions of ASP.NET.
•    Static – This specifies that the ClientID value will be the same as the ID without concatenating the IDs of parent naming containers. This can be useful in Web user controls. Because a Web user control can be located on different pages and in different container controls, it can be difficult to write client script for controls that use the AutoID algorithm because you cannot predict what the ID values will be.
•    Predictable – This option is primarily for use in data controls that use repeating templates. It concatenates the ID properties of the control’s naming containers, but generated ClientID values do not contain strings like "ctlxxx". This setting works in conjunction with the ClientIDRowSuffix property of the control. You set the ClientIDRowSuffix property to the name of a data field, and the value of that field is used as the suffix for the generated ClientID value. Typically you would use the primary key of a data record as the ClientIDRowSuffix value.
•   Inherit – This setting is the default behavior for controls; it specifies that a control’s ID generation is the same as its parent.

Query Extender – Filtering

To make data source filtering easier, a new QueryExtender control has been added in ASP.NET 4. This control can be added to EntityDataSource or LinqDataSource controls in order to filter the data returned by these controls. Because the QueryExtender control relies on LINQ, the filter is applied on the database server before the data is sent to the page, which results in very efficient operations.

The QueryExtender control supports a variety of filter options: Search,Range,Property Expression and CustomExpression.

More updates when I really work on them. Notify me incase if I had overlooked an important feature.

Happy learning!

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: