ASP.NET is a server-side technology that runs on top of the managed environment of .NET Framework. You can use ASP.NET to build and deploy web applications and develop dynamic websites. Microsoft .NET Framework is a managed platform used for designing and developing applications that are portable, scalable and robust. Microsoft's ASP.NET stands out as one of the most successful web application development frameworks ever. Over the years, it has matured enough to be the choice of web developers as a framework that you can use to develop highly scalable, high-performance web applications that leverage the features of a managed environment. ASP.NET 4.5 is shipped as part of Visual Studio 2012, and contains many new and interesting features.
ASP.NET 4.5 provides support for improved state management features. The ViewStateMode
property gives you better control over ViewState. Note that this property can have one of three values: Enabled, Disabled, or Inherit. You have another new property introduced, named ClientIDMode
. You can use this property to set the ClientID for server controls and use it from the client side. This property can have one of four values: Static, Predictable, Legacy, or Inherit.
The following script code illustrates how you can display the ClientID
for a control using JavaScript:
<script type="text/javascript"> function DisplayClientID() { alert('<%= myButtonControl.ClientID %>'), } </script>
Here's an example that shows how you can use the ClientIDMode
property:
<asp:Panel ID="pnlFirst" runat="server" ClientIDMode="Static">
The following code snippet illustrates how the Predictable
mode is used:
<asp:Content ID="contentObj" ContentPlaceHolderID="contentPlaceHolderObject" Runat="server"> <asp:Panel ID="ParentPanel" runat="server" ClientIDMode="Static"> <asp:Panel ID="ChildPanel" runat="server" ClientIDMode="Predictable"> <asp:Button ID="btnSubmit" runat="server"/> </asp:Panel> </asp:Panel> </asp:Content>
If ClientIDMode
for a control is set to Inherit
, the control inherits the ClientIDMode
setting of its parent control. Here is an example:
<asp:Content ID="contentObj" ContentPlaceHolderID="contentPlaceHolderObj" Runat="Server"> <asp:Panel ID="PanelParent" runat="server"> <asp:Panel ID="PanelChild" runat="server" ClientIDMode="Static"> <asp:Button ID="btnSubmit" runat="server" ClientIDMode="Inherit" /> </asp:Panel> </asp:Panel> </asp:Content>
ASP.NET 4.5 enables you to monitor resource utilization. To enable this resource monitoring, all you need to do is to use the following configuration in the aspnet.config
file:
<configuration> <runtime> <appDomainResourceMonitoring enabled="true"/> </runtime> </configuration>
With ASP.NET 4.x, Output Caching has improved a lot. Output Caching is a feature that enables you to store the output of your ASP.NET web pages in cache memory so that subsequent requests to the same web page can be fetched from the memory cache. By doing this, the application's performance can be improved to a great extent for web pages that contain relatively stale data.
With ASP.NET 4.x, you have a feature named Extensible Output Caching that you can use to add extensibility points to Output Caching. You can now also manage and configure one or more custom Output Cache providers. Here are the Cache Storages for which the ASP.NET 4.x Cache API provides support:
To configure your custom Output Cache provider, all you need to do is to specify the following in the application's web.config
file:
<caching> <outputCache defaultProvider="Packt.CustomCacheProvider"> <providers> <add name="DiskCache" type="Packt.CustomCacheProvider, Packt"/> </providers> </outputCache> </caching>
ASP.NET 4.x provides support for SEO. The System.Web.Routing
namespace provides support for routing through the usage of the RouteTable
and the PageRouteHandler
classes. You can also achieve SEO using the Page Meta Keyword
and Description
features available in ASP.NET 4.5, as given in the following code snippet:
protected void Page_Load(object sender, EventArgs e) { this.Page.Title = "Packt"; this.Page.MetaKeywords = "Books"; this.Page.MetaDescription = "Packt Books"; }
In this section, we will highlight some other notable enhancements in ASP.NET 4.5:
DefaultMembershipProvider
). Also, the OAuth protocol is there. OAuth is an open standard for authorizing clients to enable access to server resources on behalf of a resource owner.