April 18, 2020

Top 10 Features in ASP.NET 4.5

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

Microsoft's ASP.NET, one of the most successful web application development frameworks ever, is fast becoming mature – the newest version of it is ASP.NET 4.5. You can use ASP.NET to fast develop and deploy highly scalable, high-performance web applications in a managed environment. ASP.NET 4.5 ships as part of part of Visual Studio 2012 and contains many new and extended features. In this article we will discuss the top 10 best features in ASP.NET 4.5 for developers.

Pre-requisites

Note that ASP.NET 4.5 ships with Visual Studio 2012. To work with ASP.NET 4.5, you need to download and install Visual Studio 2012 in your system.

The Top 10 features

This section lists the 10 top features in ASP.NET 4.5.

1 - Bundling and Minification Feature

The newly introduced bundling and minification feature helps to bundle and minimize the size of the scripts and style sheets in your application. This feature has a great impact on the performance of your web application as a whole. You now have a System.Web.Optimization namespace that provides support for bundling and minification of files. Once you create a new project in ASP.NET 4.5, you'll notice these lines in your Global.asax file:

protected void Application_Start()
{
 //Some code
 BundleTable.Bundles.RegisterTemplateBundles();
}

2 - Strongly Typed Data Controls

In ASP.NET 4.5, you now have data controls that can be strongly typed. You will get intellisense - you just need to assign the ItemType property to a model that is going to be associated with the data controls used in your .aspx pages. Here is a snippet of code that illustrates how you can use this:

<asp:TemplateField HeaderText="Name" >
    <ItemTemplate>
          <%# Item.Name.ToString() %>
    </ItemTemplate>
</asp:TemplateField>

The following is a complete markup code of a GridView control that uses strong typing:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
            ModelType="Payroll">
        <Columns>
            <asp:TemplateField HeaderText="FirstName">
                <ItemTemplate>
                    <asp:Label ID="lblFirstName" runat="server" Text='<%# Item.FirstName %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="LastName">
                <ItemTemplate>
                    <asp:Label ID="lblLastName" runat="server" Text='<%# Item.LastName %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
</asp:GridView>

3 - Model Binding - Isolating the Web Form from the Model

The Model binding feature in ASP.NET 4.5 enables you to develop Webforms that are independent of the Model that populates the view. The biggest advantage of using Model Binding in ASP.NET is that you can easily unit test the methods. In ASP.NET 4.5 support for model binding is provided through the usage of the ‘System.Web.ModelBinding’ namespace. This namespace contains value provider classes like ControlAttribute, QueryStringAttribute, etc. All these classes are inherited from the ValueProviderSourceAttribute class.

Get practical knowledge on Dotnet Framework at Dot Net Online Course

4 - Value Providers

ASP.NET4.5 provides many Value Providers that can be used to filter data. These are:

  • Querystring
  • Session
  • Cookie
  • Control Value

You can also have your own custom value providers.

5 - Support for OpenID in OAuth Logins

ASP.NET 4.5 provides support for OpenID for OAuth logins - you can easily use external services to login to your application. Like ASP.NET MVC 4, ASP.NET 4.5 enables you to register OAuth provider in the App_Start/AuthConfig.cs file. We can also use this data dictionary to pass additional data.

6 - Support for improved paging in ASP.NET 4.5 GridView control

Paging support in ASP.NET 4.5 GridView control has been improved a lot. ASP.NET 4.5 GridView.AllowCustomPaging property provides great support for paging and sorting through large amounts of data efficiently.

7 - Enhanced support for asynchronous programming

ASP.NET 4.5 provides excellent support in asynchronous programming - you can now read and write HTTP requests and responses without the need of OS threads. Also, you have support for two new keywords - await and async.

8 - Support for web sockets

HTML5 WebSockets allow you to perform duplex communication between the client browser and the web server. ASP.NET 4.5 provides support for web socket protocols. ASP.NET 4.5 and IIS 8 provide support for WebSocket protocol - you can now leverage WebSockets in your ASP.NET web applications.

Support for web sockets is provided through the System.Net.WebSockets namespace.

9 - Support for HTML5 form types

ASP.NET 4.5 provides excellent support for HTML5 form types. The following are the list of new controls available in HTML5:

  • email
  • url
  • number
  • range
  • Date pickers i.e., date, month, week, time, datetime, datetime-local
  • search
  • color

10 - ASP.NET Web API

This is included in ASP.NET MVC 4 and ASP.NET Web Forms. This new ASP.NET Web API helps you to build and consume HTTP services easily.