whats new in asp.net 4.0

34
What's new in ASP.NET 4.0 Sunil Pottumuttu Quick Overview of Important Features

Upload: pysunil

Post on 02-Jun-2015

1.779 views

Category:

Education


3 download

DESCRIPTION

Important Features of ASP.NET 4.0

TRANSCRIPT

Page 1: Whats new in ASP.NET 4.0

What's new in ASP.NET 4.0

Sunil Pottumuttu

Quick Overview of Important Features

Page 2: Whats new in ASP.NET 4.0

ASP.NET 3.5 Service Pack 1

Microsoft Entity FrameworkADO.NET Data ServicesDynamic Data

Page 3: Whats new in ASP.NET 4.0

Overview of Talk

ASP.NET supports several very different types of web applications

.NET Framework

ASP.NET Framework

ASP.NETWeb

Forms

ASP.NET MVC

ASP.NET

AJAX

ASP.NETDynamic

Data

Page 4: Whats new in ASP.NET 4.0

Web.config File Refactoring <?xml version="1.0"?> <configuration> <system.web> <compilation targetFramework="4.0" /> </system.web> </configuration>

Page 5: Whats new in ASP.NET 4.0

Extensible Output Caching

ASP.NET 4.0 OutputCacheProvider - create a custom output-cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider

Providers for 3rd Party, Velocity, FileSystem

Page 6: Whats new in ASP.NET 4.0

Output Caching Configuration<caching> <outputCache

defaultProvider="AspNetInternalProvider"> <providers> <add name="DiskCache" type="Test.OutputCacheEx.DiskOutputCachePro

vider, DiskCacheProvider"/> </providers> </outputCache> </caching>

Page 7: Whats new in ASP.NET 4.0

Output Caching Configuration at Page Level

<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>

Page 8: Whats new in ASP.NET 4.0

Auto-Start Web Applications

Usual approach: Application_StartAuto-Start

ASP.NET 4.0 + IIS 7.5AppPool startMode set to “alwaysRunning”IIS Application Warm-Up Module for IIS 7.5

warm-up occurs during startup of the IIS service (if you configured the IIS application pool as AlwaysRunning) and when an IIS worker process recycles. During recycle, the old IIS worker process continues to execute requests until the newly spawned worker process is fully warmed up, so that applications experience no interruptions or other issues due to unprimed caches

Page 9: Whats new in ASP.NET 4.0

IIS Configuration for the above

In applicationHost.config

<applicationPools> <add name="MyApplicationPool"

startMode="AlwaysRunning" /> </applicationPools>

Page 10: Whats new in ASP.NET 4.0

Permanently Redirecting a Page

RedirectPermanent("/newpath/foroldcontent.aspx");

Page 11: Whats new in ASP.NET 4.0

Session State CompressionUsed when state is out of porcesscompressionEnabled in web.configDeflateStream/GZipStream Use System.IO.Compression.GZipStream Web.config

<sessionState mode="SqlServer" sqlConnectionString="data

source=dbserver;Initial Catalog=aspnetstate"

allowCustomSqlDatabase="true" compressionEnabled="true“

/>

Page 12: Whats new in ASP.NET 4.0

Expanding the Range of Allowable URLs

Previous versions of ASP.NET constrained URL path lengths to 260 characters, based on the NTFS file-path limit.

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />

Page 13: Whats new in ASP.NET 4.0

Request Path Valid Chars

ASP.NET, the URL character checks were limited to a fixed set of characters. In ASP.NET 4, you can customize the set of valid characters using the new requestPathInvalidChars attribute of the httpRuntime configuration element

<httpRuntime requestPathInvalidChars="&lt;,&gt;,*,%,&amp;,:,\,?" />

By default, the requestPathInvalidChars attribute defines eight characters as invalid. (In the string that is assigned to requestPathInvalidChars by default, the less than (<), greater than (>), and ampersand (&) characters are encoded, because the Web.config file is an XML file.) You can customize the set of invalid characters as needed

Page 14: Whats new in ASP.NET 4.0

Extensible Request Validation System.Web.Util.RequestValidator

<httpRuntime requestValidationType="Samples.MyValidator, Samples" />

public class CustomRequestValidation : RequestValidator

{ protected override bool IsValidRequestString( HttpContext context, string value, RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex) {...} }

Page 15: Whats new in ASP.NET 4.0

Object Caching and Object Caching Extensibility

System.Runtime.Caching.dllCan Implement MemoryCache

Page 16: Whats new in ASP.NET 4.0

Extensible HTML, URL, and HTTP Header Encoding

<httpRuntime encoderType="Samples.MyCustomEncoder, Samples" />

You can create a custom encoder by deriving from the new System.Web.Util.HttpEncoder

After a custom encoder has been configured, ASP.NET automatically calls the custom encoding implementation whenever public encoding methods of the System.Web.HttpUtility or System.Web.HttpServerUtility classes are called

Page 17: Whats new in ASP.NET 4.0

Multi-Targeting

• <compilation targetFramework="4.0"/>

Page 18: Whats new in ASP.NET 4.0

jQuery Included with Web Forms and MVC

jQuery-1.4.1.js – The human-readable, unminified version of the jQuery library. jQuery-14.1.min.js – The minified version of the jQuery library. jQuery-1.4.1-vsdoc.js – The Intellisense documentation file for the jQuery library.

Page 19: Whats new in ASP.NET 4.0

Content Delivery Network Support

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" type="text/javascript"></script>

Supports SSLMore Details here:

http://www.asp.net/ajaxlibrary/CDN.ashx

ASP.NET ScriptManager supports the Microsoft Ajax CDN

<asp:ScriptManager ID="sm1" EnableCdn="true" runat="server" />

Page 20: Whats new in ASP.NET 4.0

ScriptManager Explicit Scripts

<asp:ScriptManager ID="sm1" AjaxFrameworkMode="Explicit" runat="server">

<Scripts> <asp:ScriptReference

Name="MicrosoftAjaxCore.js" /> <asp:ScriptReference

Name="MicrosoftAjaxComponentModel.js" /><asp:ScriptReference

Name="MicrosoftAjaxSerialization.js" /> <asp:ScriptReference

Name="MicrosoftAjaxNetwork.js" /> </Scripts> </asp:ScriptManager>

** ScriptManager.AjaxFrameworkMode

Page 21: Whats new in ASP.NET 4.0

Setting Meta TagsPage.MetaKeywords and Page.MetaDescription

Properties of Page class

<meta name="keywords" content="These, are, my, keywords" />

<meta name="description" content="This is the description of my page" />

OR

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Keywords="These, are, my, keywords" Description="This is a description" %>

Page 22: Whats new in ASP.NET 4.0

Enabling View State for Individual Controls

ViewStateMode Property EnabledDisabledInherit

Enabled enables view state for that control and for any child controls that are set to Inherit or that have nothing set. Disabled disables view state, and Inherit specifies that the control uses the ViewStateMode setting from the parent control

Page 23: Whats new in ASP.NET 4.0

ASP.NET Core Enhancements

Cache Extensibility

Auto-Start Web Applications

Browser Capabilities Extensibility

Session State Compression

Page 24: Whats new in ASP.NET 4.0

ASP.NET Core Enhancements

Cache Extensibility

Auto-Start Web Applications

Browser Capabilities Extensibility

Session State Compression

Page 25: Whats new in ASP.NET 4.0

Browser Definition Files

blackberry.browser chrome.browser Default.browser firefox.browser gateway.browser

generic.browser ie.browser iemobile.browser iphone.browser opera.browser safari.browser

Page 26: Whats new in ASP.NET 4.0

Routing in ASP.NET 4public class Global : System.Web.HttpApplication {

void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapPageRoute("SearchRoute", "search/{searchterm}", "~/search.aspx"); RouteTable.Routes.MapPageRoute("UserRoute", "users/{username}", "~/users.aspx"); }

}

Equivalent asp.net 4 RouteTable.Routes.Add("SearchRoute", new Route("search/{searchterm}", new PageRouteHandler("~/search.aspx")));

string searchterm = Page.RouteData.Values["searchterm"] as string;

Page 27: Whats new in ASP.NET 4.0

Accessing Routing Information in Markup

<asp:HyperLink ID="HyperLink1" runat="server"

NavigateUrl="<%$RouteUrl:SearchTerm=scott%>">Search for Scott</asp:HyperLink>

Page 28: Whats new in ASP.NET 4.0

Setting Client IDs

Predictable Client ID’s

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

OR <system.web> <pages clientIDMode="Predictable"></pages> </system.web>

Page 29: Whats new in ASP.NET 4.0

Chart Control

35 distinct chart types. An unlimited number of chart areas, titles, legends, and annotations. A wide variety of appearance settings for all chart elements. 3-D support for most chart types. More than 50 financial and statistical formulas for data analysis and transformation.State management. Binary streaming.

Page 30: Whats new in ASP.NET 4.0

New Syntax for HTML Encoded Expressions

Old Style <%= HttpUtility.HtmlEncode(expression) %>

New style<%: expression %>

Page 31: Whats new in ASP.NET 4.0

Project Template ChangesWeb Site project or Web Application project

Page 32: Whats new in ASP.NET 4.0

Empty Web Application Template

Page 33: Whats new in ASP.NET 4.0

Web Application and Web Site Project Templates

Page 34: Whats new in ASP.NET 4.0

Dynamic Data

• RAD experience for quickly building a data-driven Web site. • Automatic validation that is based on constraints defined in the data model. • The ability to easily change the markup that is generated for fields in the

GridView and DetailsView controls by using field templates that are part of your Dynamic Data project.