New Features in ASP.NET 4.0

author-image
PCQ Bureau
New Update

Joydip Kanjilal, Software Consultant and Author

ASP.NET is  the most popular Web application framework for
programmers to build dynamic websites and services. The language-neutral,
interoperable server side technology runs on top of the managed environment of .NET's
CLR and within the context of a web server like IIS, and allows creation,
execution, and deployment of scalable Web Apps and services seamlessly. To work
with ASP.NET 4.0, you need to have Visual Studio 2010 installed on your system.
You can download  Beta 2 of the same from here: http://tinyurl.com/o949y9  Let's
take a look at the new features of ASP.NET 4.0.

State management improvements

In ASP.NET 4.0, there has been marked improvements in Cache, Session and
ViewState. The  Cache API now allows you to store data in any of the following
cache storages; disk-based output caches -used to store cache data in disk,
custom object caches -used to store cache data using custom cache providers,
distributed object caches -used to store cache data in a separate server and
Cloud-based object caches -used to store cache data in Cloud databases.  Now you
can use ASP.NET 4.0 Cache API to design and implement your custom cache storage
provider too. You can also configure your custom cache provider easily in your
application's web.config file. Here's an example:

Direct Hit!

Applies To: .NET Developers

USP: Learn about features that improve core ASP.NET services

Primary Link: Link:
http://tinyurl.com/y9w3gcw



http://www.ciol.com/sparkIT/2010


Search Engine Keywords: ASP.NET 4







type="MyDiskCacheProvider.OutputCacheEx.DiskOutputCacheProvider,MyDiskCacheProvider"/>




There has also been a marked improvement in ViewState in
ASP.NET 4.0. You can now use the ViewStateMode property -a new property
introduced for all controls in ASP.NET 4.0, to determine whether or not
ViewState should be enabled for a particular control in your webform. This gives
your better control and flexibility on the ViewState.

Enhancements to ASP.NET data presentation controls

In ASP.NET 4.0, the LayoutTemplate of the ListView control is optional. You
can now use the ItemTemplate of the ListView control to display and manage your
data. Here is an example:


ClientIDMode="Predictable">



Customer Code:

/>




Customer Name:

/>




Another improvement in ASP.NET 4.0 is the introduction of a
new property called RepeatLayout in the RadioButtonList and CheckBoxList
controls.

Support for performance monitoring

You can turn on application resource monitoring feature for your
applications by using the following configuration in the aspnet.config file:









It should be noted that when the
appDomainResourceMonitoring feature is enabled in your application, two new
performance counters are distinctly visible in the "ASP.NET Applications
Performance" category. These include '% Managed Processor Time' and 'Managed
Memory Used'.

Enhanced control over ControlIDs of controls

You can have better control over the controlIDs of your data controls in the
web page. ASP.NET 4.0 introduces a new property called ClientIDMode for each and
every control. This property can have any one of the following possible values;
AutoID, Inherit, Static, and Predictable. Note that you can set the ClientIDMode
property at the page, application and even at the control levels. The following
code snippet illustrates how you can set the ClientIDMode at the application
level:




The following code snippet illustrates how you can set the
ClientIDMode for a TextBox control in your markup code:

runat="server" ClientIDMode="Static" />

To set the ClientIDMode property at the control level, you
can use the foollowing syntax:

ID="GridView1" AutoGenerateColumns="False" ClientIDMode="AutoID">

And, here is how you can set the ClientIDMode property at
the page level:

<%@ Page Language="C#"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
ClientIDMode="Predictable" %>

Support for Routing

Routing was initially introduced in ASP.NET MVC Framework.
With ASP.NET 4.0, Routing has been made a feature of ASP.NET. You can use
Routing to map specific resources using user friendly URLs. Note that support
for Webform Routing in ASP.NET 4.0 is provided by the System.Web.Routing
namespace.

SEO enhancements

In ASP.NET 4.0 there are two new properties in your Page class -Keywords and
Description, that you can use to optimize searches. The following code
illustrates how you can set these properties using C# code in the code behind
file for your web form:

public partial class TestWebForm :
System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Page.Keywords = "ASP.NET 4.0 Programming by Joydip Kanjilal";

Page.Description = "PC Quest";

}

}

It is also possible to achieve the same using markup code.
Here is an example:





ASP.NET 4.0 Programming by Joydip Kanjilal





Simplification of Web.Config file

The web.config file in ASP.NET 4.0 is much simplified. Most of the
configuration elements have now been moved to the machine.config file. This
results in reduced size of the web.config file. You can now specify the
framework that your application is designed to be targeted at. To do this, you
can simply specify the following in your application's web.config file:









About the Author : Joydip Kanjilal  has over 12
years of industry experience in IT with more than 6 years in Microsoft .NET &
its related technologies.  Joydip has authored several books on ASP.NET.

Stay connected with us through our social media channels for the latest updates and news!

Follow us: