new features of asp.net 4 0

23
What’s new in ASP.Net 4.0 February, 2010 Dmytro Maleev

Upload: dima-maleev

Post on 10-May-2015

21.616 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: New Features Of ASP.Net 4 0

What’s new in ASP.Net 4.0

February, 2010Dmytro Maleev

Page 2: New Features Of ASP.Net 4 0

2

History of ASP.Net

Changes to Core Services

Changes to Web Forms

Visual Studio 2010 Web Designer Improvements

Q&A

Agenda

Page 3: New Features Of ASP.Net 4 0

3

History of ASP.Net

ASP.Net 1.0

January 2002

ASP.Net 1.1

April 2003

ASP Classic

CLR 1 CLR 1.1 CLR 2.0

ASP.Net 2.0

November 2005

ASP.Net 3.0

November 2006

ASP.Net 3.5

November 2007

ASP.Net 3.5 SP1

August 2008

CLR 4.0

ASP.Net 4.0

Page 4: New Features Of ASP.Net 4 0

4

ASP.Net 4.0 Components

ASP.Net Web Forms

ASP.Net AJAX ASP.Net MVCASP.Net

Dynamic Data

ASP.Net Framework

.Net Framework

Page 5: New Features Of ASP.Net 4 0

5

Web.config File Minification

Auto-Start Web Applications

Requires IIS 7.5

The Incredible Shrinking Session State

Using GZipStreamClass

Changes to Core Services

Page 6: New Features Of ASP.Net 4 0

6

Possibility of creation of own Cache storage:

Memory

Local or remote drive

Cloud services

Distributed cache engines

Extending web.config with new element:

Extensible Output Caching

Page 7: New Features Of ASP.Net 4 0

7

Possibility of creation Cache Providers:

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

Usage of different cache providers for different pages:

Extensible Output Caching

Page 8: New Features Of ASP.Net 4 0

8

Expanding the Range of Allowable URLs

ASP.NET 4 introduces new options for expanding the size of application URLs. Previous versions of ASP.NET constrained URL path lengths to 260 characters (based on the NTFS file-path limit).  In ASP.NET 4, you have the option to increase (or decrease) this limit as appropriate for your applications, using two new httpRuntime configuration attributes. The following example shows these new attributes.

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

Uri characters check

ASP.NET 4 also enables you to configure the characters that are used by the URL character check.  When ASP.NET finds an invalid character in the path portion of a URL, it rejects the request and issues an HTTP 400 error.  In previous versions of 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, as shown in the following example:

<httpRuntime requestPathInvalidChars="<,>,*,%,&,:,\" />

Permanently Redirecting a PageIt is common practice in Web applications to move pages and other content around over time, which can lead to an accumulation of stale links in search engines. In ASP.NET, developers have traditionally handled requests to old URLs by using by using the Response.Redirect method to forward a request to the new URL. However, the Redirect method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs.

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

URLs improving

Page 9: New Features Of ASP.Net 4 0

9

ASP.NET request validation searches incoming HTTP request data for strings that are commonly used in cross-site scripting (XSS) attacks. If potential XSS strings are found, request validation flags the suspect string and returns an error. The built-in request validation returns an error only when it finds the most common strings used in XSS attacks. Previous attempts to make the XSS validation more aggressive resulted in too many false positives. However, customers might want request validation that is more aggressive, or conversely might want to intentionally relax XSS checks for specific pages or for specific types of requests.

Custom validation:<httpRuntime requestValidationType="Samples.MyValidator, Samples" />

public class MyValidator: RequestValidator

{

protected override bool IsValidRequestString( HttpContext context, string value,

RequestValidationSource requestValidationSource,

string collectionKey, out int validationFailureIndex)

{...}

}

Request validation

Page 10: New Features Of ASP.Net 4 0

10

In order to increase the number of Web sites that can be hosted on a single server, many hosters run multiple ASP.NET applications in a single worker process. However, if multiple applications use a single shared worker process, it is difficult for server administrators to identify an individual application that is experiencing problems.

ASP.NET 4 leverages new resource-monitoring functionality introduced by the CLR.  To enable this functionality, you can add the following XML configuration snippet to the aspnet.config configuration file.

<?xml version="1.0" encoding="UTF-8" ?> <configuration>

<runtime> <appDomainResourceMonitoring enabled="true"/>

</runtime> </configuration>

Performance Monitoring

Page 11: New Features Of ASP.Net 4 0

11

You can create an application that targets a specific version of the .NET Framework. In ASP.NET 4, a new attribute in the compilation element of the Web.config file lets you target the .NET Framework 4 and later. If you explicitly target the .NET Framework 4, and if you include optional elements in the Web.config file such as the entries for system.codedom, these elements must be correct for the .NET Framework 4. (If you do not explicitly target the .NET Framework 4, the target framework is inferred from the lack of an entry in the Web.config file.)

<compilation targetFramework="4.0"/>

Note the following about targeting a specific version of the .NET Framework: In a .NET Framework 4 application pool, the ASP.NET build system assumes the .NET Framework 4 as a target if the Web.config file does

not include thetargetFramework attribute or if the Web.config file is missing. (You might have to make coding changes to your application to make it run under the .NET Framework 4.)

If you do include the targetFramework attribute, and if the system.codeDom element is defined in the Web.config file, this file must contain the correct entries for the .NET Framework 4.

If you are using the aspnet_compiler command to precompile your application (such as in a build environment), you must use the correct version of theaspnet_compiler command for the target framework. Use the compiler shipped in the .NET Framework 2.0 (%WINDIR%\Microsoft.NET\Framework\v2.0.50727) to compile for the .NET Framework 3.5 and earlier versions. Use the compiler shipped in the .NET Framework 4 to compile applications created with that framework or later versions.

At run time, the compiler uses the latest framework assemblies that are installed on the computer (and therefore in the GAC). If an update is made later to the framework (for example, a hypothetical version 4.1 is installed), you will be able to use features in the newer version of the framework even though thetargetFramework attribute targets a lower version (such as 4.0). (However, at design time in Visual Studio 2010 or when you use the aspnet_compiler command, using newer features of the framework will cause compiler errors).

Multi-Targeting

Page 12: New Features Of ASP.Net 4 0

12

Setting Meta TagsView State improvementsQuery Extender ControlASP.NET ChartCSS ImprovementsListView improvementsFormView improvementsSetting Client IDsRouting in ASP.NET 4Changes to Browser Capabilities

Changes to Web Forms

Page 13: New Features Of ASP.Net 4 0

13

One of the smaller additions that has been made to ASP.NET 4 Web Forms is the addition of two properties to the Page class, MetaKeywords and MetaDescription. These two properties represent corresponding meta tags in your page, as shown in the following example:

<head id="Head1" runat="server"> <title>Untitled Page</title> <meta name="keywords" content="These, are, my, keywords" /> <meta name="description" content="This is the description of my page" />

</head>

You can set these properties at run time, which lets you get the content from a database or other source, and which lets you set the tags dynamically to describe what a particular page is for.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Keywords="These, are, my, keywords" Description="This is a description" %>

Setting Meta Tags

Page 14: New Features Of ASP.Net 4 0

14

New property: ViewStateMode

 By default, view state is enabled for the page, with the result that each control on the page potentially stores view state even if it is not required for the application. View state data is included in a page's HTML and increases the amount of time it takes to send a page to the client and post it back. Storing more view state than is necessary can cause significant performance degradation. In earlier versions of ASP.NET, developers could disable view state for individual controls in order to reduce page size, but had to do so explicitly for individual controls. In ASP.NET 4, Web server controls include a ViewStateMode property that lets you disable view state by default and then enable it only for the controls that require it in the page.

The ViewStateMode property takes an enumeration that has three values: Enabled, Disabled, and Inherit. 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.

Enabled 

Disabled

Inherit

View State improvements and Query Extender

Page 15: New Features Of ASP.Net 4 0

15

Search<asp:LinqDataSource ID="dataSource" runat="server"> TableName="Products"> </asp:LinqDataSource> <asp:QueryExtender TargetControlID="dataSource" runat="server">

<asp:SearchExpression DataFields="ProductName, Supplier.CompanyName" SearchType="StartsWith"> <asp:ControlParameter ControlID="TextBoxSearch" />

</asp:SearchExpression> </asp:QueryExtender>

Range<asp:LinqDataSource ID="dataSource" runat="server"> TableName="Products"> </asp:LinqDataSource> <asp:QueryExtender TargetControlID="dataSource" runat="server">

<asp:RangeExpression DataField="UnitPrice" MinType="Inclusive" MaxType="Inclusive"> <asp:ControlParameter ControlID="TextBoxFrom" /> <asp:ControlParameter ControlID="TexBoxTo" />

</asp:RangeExpression> </asp:QueryExtender>

CustomExpression

<asp:LinqDataSource ID="dataSource" runat="server" TableName="Products"> </asp:LinqDataSource>

<asp:QueryExtender TargetControlID="dataSource" runat="server">

<asp:CustomExpression OnQuerying="FilterProducts" />

</asp:QueryExtender>

protected void FilterProducts(object sender, CustomExpressionEventArgs e)

{

e.Query = from p in e.Query.Cast<Product>() where p.UnitPrice >= 10 select p;

}

Query Extender Control

Page 16: New Features Of ASP.Net 4 0

16

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.

Smart data labels that can automatically fit around data points.

Strip lines, scale breaks, and logarithmic scaling.

More than 50 financial and statistical formulas for data analysis and transformation.

Simple binding and manipulation of chart data.

Support for common data formats, such as dates, times, and currency.

Support for interactivity and event-driven customization, including client click events using AJAX.

State management.

Binary streaming.

ASP.NET Chart Control

Page 17: New Features Of ASP.Net 4 0

17

ASP.NET Chart Control Screens

Page 18: New Features Of ASP.Net 4 0

18

Support of the CSS 2.1

ListView improvements

No layout templates<asp:ListView ID="list1" runat="server">

<ItemTemplate> <%# Eval("LastName")%>

</ItemTemplate> </asp:ListView>

RenderOuterTable property

controlRenderingCompatabilityVersion

CheckBoxList and RadioButtonList improvements (OrderedList , UnorderedList )

Setting Client IDs AutoID

Static

Predictable 

Inherit

Other Web Forms improvements

Page 19: New Features Of ASP.Net 4 0

19

ASP.NET 4 adds built-in support for using routing with Web Forms. Routing lets you configure an application to accept request URLs that do not map to physical files. Instead, you can use routing to define URLs that are meaningful to users and that can help with search-engine optimization (SEO) for your application. For example, the URL for a page that displays product categories in an existing application might look like the following example:

http://website/products.aspx?categoryid=12 equals http://website/products/software

Global Routing

public 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"); }

}

Page level routingRouteTable.Routes.Add("SearchRoute", new Route("search/{searchterm}", new PageRouteHandler("~/search.aspx")));

Routing in ASP.NET 4

Page 20: New Features Of ASP.Net 4 0

20

The HttpBrowserCapabilities object is driven by a set of browser definition files. These files contain information about the capabilities of particular browsers. In ASP.NET 4, these browser definition files have been updated to contain information about recently introduced browsers and devices such as Google Chrome, Research in Motion BlackBerry smartphones, and Apple iPhone.

blackberry.browser

chrome.browser

Default.browser

firefox.browser

gateway.browser

generic.browser

ie.browser

iemobile.browser

iphone.browser

opera.browser

safari.browser

Changes to Browser Capabilities

Page 21: New Features Of ASP.Net 4 0

21

HTML and JScript Snippets

Over 200  that help you auto-complete common

ASP.NET and HTML tags, including required attributes (such asrunat="server") and common attributes specific to a tag (such as ID, DataSourceID, ControlToValidate, and Text).

JScript IntelliSense EnhancementsIn Visual 2010, JScript IntelliSense has been redesigned to provide an even richer editing experience. IntelliSense now recognizes objects that have been dynamically generated by methods such as registerNamespace and by similar techniques used by other JavaScript frameworks. Performance has been improved to analyze large libraries of script and to display IntelliSense with little or no processing delay. Compatibility has been dramatically increased to support nearly all third-party libraries and to support diverse coding styles. Documentation comments are now parsed as you type and are immediately leveraged by IntelliSense.

Visual Studio 2010 Web Designer Improvements

Page 22: New Features Of ASP.Net 4 0

22

What’s new in ASP.Net 4.0

http://www.asp.net/learn/whitepapers/aspnet40/

Presentation about new features of ASP.Net 4.0 by Microsoft Ukraine

http://www.slideshare.net/akrakovetsky/aspnet-4

CSS 2.1 Specification

http://www.w3.org/TR/CSS2/

MSDN ViewState Modes

http://msdn.microsoft.com/en-us/library/system.web.ui.viewstatemode(VS.100).aspx

ASP.Net 4.0 RoadMap

http://channel9.msdn.com/pdc2008/PC20/

References

Page 23: New Features Of ASP.Net 4 0

23

Q&A