dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersDanasegarane.A
Sameer Sayani
naveensanagasetti
Padma
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » .NET programming » ASP.NET/Web Applications

New features of ASP.NET 4.0


Posted Date:     Category: ASP.NET/Web Applications    
Author: Member Level: Gold    Points: 20


Microsoft has introduced many new features for the both .NET Framework and ASp.NET along with C#. The Dynamic Keyword and Named and Optional Parameters are newly introduced in C#.net 4.0. Below are the newly introduced features in ASP.NET 4.0 version.



 


1) Output cache extensibility
2) Refactoring Web.config file
3) Session state compression
4) Better control of the ViewState
5) Page.MetaKeyword and Page.MetaDescription propertie.

Output cache extensibility:


As we all know, caching is a coolest feature in ASP.NET. Caching enables you to store the expensive data into the application server memory and it is useful for the later retrieval. For example when you are retrieving the large amount of data from the database, it is tedious to fetch the data from database every time. At this situation we are using the ASP.NET feature caching. It saves the data in the webserver, but this may be slow down the web application and that may cause to another sites which may deploy in the same server.
For the above reason, Microsoft has introduced Output cache extensibility feature along with ASP.NET 4.0 release. The ASP.NET 4.0 developers may extend their caching by using Output cache providers. Now developers needs to create Output cache providers to cache the output data in the in any persistent mechanism like database, clusters, cloud storage, distributed cache engines etc. You should configure the web.config file like as below.

<system.web>
<compilation debug="true" targetFramework="4.0" />
<caching>
<outputCache defaultProvider="mySampleOutputCache">
<providers>
<add name="myCache" type="mySampleCustomCache, exampleCache"/>
</providers>
</outputCache>
</caching>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
</system.web>

A class System.Web.Caching.OutputCacheProvider is useful to create the custom Output cache in your web page. Once you add the below code to your aspx page the output cache will start use the custom one and store in the server which you have specified.

<%@ OutputCache Duration="180" VaryByParam="None" %>

Refactoring Web.config file:


Over the past few years web.config has grown significantly as features of ASP.NET has increased day by day such as routing, Ajax, IIS 7 and version compatibility. It is very difficult to maintain all the features in Visual Studio.
With ASP.NET 4, most of the major elements moved to machine.config file. This has enabled developers to maintain a cleaner, less cluttered, web.config file. The new web.config file is either empty, or includes just the .NET framework version details as shown in the following example.

<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>

Session state compression :


The ASP.NET session state is a mechanism to save the session's state data and maintain across the pages requests. We having different types of Session state mechanism in ASP.NET, those are InProc, OutProc and SqlServer. We can save the sessions data in the state server, but when we have the large amount of data generally needs to be serialized and send to the server, latency time may be increase and application performance may be affected. To avoid this situation .NET introduce the compressionEnabled mechanism to compress the session data and save in the sql server.

<system.web>
<compilation debug="true" targetFramework="4.0" />
<sessionState mode="SQLServer" sqlConnectionString="data source=DBServr;Initial Catalog=PMDB" allowCustomSqlDatabase="true" compressionEnabled="true"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
</system.web>

Better control of the ViewState:



View state is a feature in ASP.NET to maintain the page control state between the subsequent post backs. Asp.NET saves the data for its controls even those data is not required. This data will be save in the browser memory and may degrade the application performance.

ASP.NET 4.0 introduce the property ViewStateMode for each control, by default ViewStateMode is
Disabled and you need to enable if you require the control data in view state.


<asp:TextBox ID="TextBox1" runat="server" ViewStateMode="Enabled"></asp:TextBox>
<asp:CheckBox ID="CheckBox1" runat="server" ViewStateMode="Disabled" />


Page.MetaKeyword and Page.MetaDescription properties:


To increase the relevance of page searches we have to add the description and key words in Meta tag html head section, but that will take a time do these activities. In ASP.NET 4.0 they have introduced the Page properties like Page.MetaKeyword and Page.MetaDescription, you need to set these properties in the page load event of a webpage.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication4
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.MetaDescription = "My sample page description";
Page.MetaKeywords = "My Page";
}
}
}





Did you like this resource? Share it with your friends and show your love!


Responses to "New features of ASP.NET 4.0"
Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Sample Login Page in ASP.NET
    Previous Resource: What is Lambda expressions in C# programming?
    Return to Resources
    Post New Resource
    Category: ASP.NET/Web Applications


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    ASP.NET 4.0 Features  .  New features of ASP.NET 4.0  .  Features ASP.NET 4.0  .  Output cache extensibility in ASP.NET 4.0  .  Refactoring Web.config file in ASP.NET 4.0  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.