asp.net 4.0

30
In collaborazione con ASP.net 4.0 WebForm and Core Runtime Le novità per lo sviluppo web(Form) e del runtime » Andrea Colaci

Upload: xedotnet

Post on 13-May-2015

2.301 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: ASP.NET 4.0

In collaborazione con

ASP.net 4.0 WebForm and Core RuntimeLe novità per lo sviluppo web(Form) e del runtime

» Andrea Colaci

Page 2: ASP.NET 4.0

» ASP.net 4.0 WebForm• New project templates, snippets, deployment• Controls (ClientId, ViewState)• Routing• Deployment

» ASP.net 4.0 Runtime• appDomain Resource Monitoring «ARM»• IIS integration: wp auto-start & application warm-up• Session Activation & Compression• OutputCache provider extensibility, out-of-proc Cache

Agenda

Page 3: ASP.NET 4.0

ASP.net 4.0 WebForm

» Visual Studio 2010• New project templates, JQuery, snippets

» Server controls enhancements• New browser-capability files (nuovi devices)• CheckBoxList, RadioButtonList

• RepeatLayout: UnorderedList, OrderedList, Flow, Table• ChangePassword, FormView, Login, PasswordRecovery

• RenderOuterTable

» Granular ViewState, ClientId» Routing in WebForm 4.0» Deployment

Page 4: ASP.NET 4.0

Granular ViewState

@Page EnableViewState=False

Control1 ViewStateMode=Enabled

Page 5: ASP.NET 4.0

ClientID

» AutoId: generato automaticamente• Ctr00_ShopCartExpanded

» Static: impostato manualmente (da markup)• ShopCartExpanded

» Inherit: stessa modalità controllo parent.» Predictable: per controlli databound, ClientIdRowSuffix

(suffisso = proprietà del DataSource es. ProductId)• Ctr10_Quantity_775

Page 6: ASP.NET 4.0

ClientID

“It is up to you to make sure that the rendered control IDs are unique.If they are not, it can break any functionality that requires unique IDs for individual HTML elements, such as the client document.getElementById function.”

Fonte: ASP.net 4.0 Whitepaper

Page 7: ASP.NET 4.0

www.xedotnet.org 717/01/2008

VS2010, Granular ViewState, ControlId

DEMO

Page 8: ASP.NET 4.0

Routing

www.mySite.com/BikesCatalog.aspx?Year=2010&CategoryId=79&Page=2

www.mySite.com/2010/Bikes/OffRoad/2

» Hackable urls» SEO friendly» Discaccoppiamento tra url fisico e logico» Gestione centralizzata

Page 9: ASP.NET 4.0

Routing != URL Rewriting

» ASP.Net UrlMappings (dalla 2.0)» Riscrive l’url prima che la request sia gestita (Module)» Sintassi dichiarativa (web.config)» Impatto (quasi) zero

» URLRewriter.net+ API+ RegEx per manipolazione Querystring+ Form proprietario (gestione postback)

Page 10: ASP.NET 4.0

Routing != URL Rewriting

Page 11: ASP.NET 4.0

ASP.net 4.0 Routing

» REST-ful» Introdotto in ASP.net 3.5 SP1» Evoluto con ASP.net MVC» Disponibile a pieno titolo in WebForm

4.0» System.Web.Routing

UrlRoutingModule RouteTable Expression builders (<%$ ... %>)

RouteUrlExpressionBuilder RouteValueExpressionBuilder

Page 12: ASP.NET 4.0

Routing

Request UrlRoutingModuleIHttpModule

RouteTable

PageRouteHandler

Catalog.aspx IHttpHandler

Response

Route Pattern Handler

Catalog/{Category} Catalog.aspx

Product/{ProductId} Product.aspx

... ...

PageRouteHandler

CustomRouteHandler

ProcessRequest(HttpContext context)

www.mySite.com/Catalog/Bikes

Page 13: ASP.NET 4.0

www.xedotnet.org 1317/01/2008

Routing

DEMO

Page 14: ASP.NET 4.0

Deployment

» Web.config transformations (simile ad EntLib configuration, ma basato XSLT)

» Web Packages (MSDeploy) IIS Settings, GAC, COM, SQL DB,

Security» One-click Publishing

Sfrutta IIS Remote Management Hosters che supportano One-click

(vedi links)

Page 15: ASP.NET 4.0

Web.config transformations

Transform Descriptionxdt:Transform=“Replace” Replaces the first matched node

xdt:Transform=“Remove” Removes the first matched node

xdt:Transform=“RemoveAll” Removes all the matching nodes

xdt:Transform=“Insert” Inserts the node at the end

xdt:Transform=“SetAttributes(attributeNames)” Creates or changes values of the existing attributes

xdt:Transform=“RemoveAttributes(attributeNames)” Removes the attributes if they exist

xdt:Transform=“InsertBefore(XPath)” Inserts the node on the provided Xpath

xdt:Transform=“InsertAfter(XPath)” Inserts the node on the provided XPath

Page 16: ASP.NET 4.0

Web deployment

» Pages» Content» IIS Settings» Database Schema + Data + Custom

Scripts

Page 17: ASP.NET 4.0

www.xedotnet.org 1717/01/2008

Web.config transform, one-click deployment

DEMO

Page 18: ASP.NET 4.0

www.xedotnet.org 1817/01/2008

PARTE 2: RUNTIME

Page 19: ASP.NET 4.0

ARM (appDomain resource monitoring)

» Introdotti con in CLR 4» ASP.net espone perf. Counters per ogni AppDomain

Managed Memory Used % Managed Processor Time …

» Deve essere abilitato (è off di default) Aspnet.config (IIS-CLR low level settings) Implica un overhead Campionamento ogni 5 secondi

Page 20: ASP.NET 4.0

www.xedotnet.org 2017/01/2008

ARM AppDomain Resource Monitoring

DEMO

Page 21: ASP.NET 4.0

IIS 7.5 integration & warm-up

» IIS 7.5 Auto-start worker process

Http services Non http services (WCF netTcp, WF)

Il team di IIS ha creato un application Warm-up module Sfruttabile da applicazioni ASP.net < 4.0 Si integra con applicazioni ASP.net 4.0 (web.config)

» Application Warm-Up Utile in contesti di sincronizzazione di più applicazioni Fornisce un entry point per eseguire codice custom di inizializzazione

(no HttpContext) ApplicationHost.config (%windir%\system32\inetsrv\config) IProcessHostPreloadClient

Page 22: ASP.NET 4.0

IProcessHostPreloadClient

AppPool

Consumer App

Business App

Cache Custom Warm-up code IProcessHostPreloadClient

Data Store

Request

Request

Request

Page 23: ASP.NET 4.0

Windows Server AppFabric Caching (a.k.a. Velocity)

Cache distribuita (MemCached, ScaleOut State Server, NCache)» In-memory, scalabile, fault-tolerant» Componente di Windows Server 2008

• Server installabile anche su Windows7 e Vista• H.A. richiede Windows Server 2008 Enterprise

» Parte server richiede .net fx 4.0» Client library richiede .net fx 3.5 o superiore» SessionProvider per ASP.net (3.5)

AppFabric Cache

Page 24: ASP.NET 4.0

www.xedotnet.org 2417/01/2008

IIS 7.5 integration & warm-up

DEMO

Page 25: ASP.NET 4.0

Session in ASP.net 4.0

» Automatic compression Si abilita da web.config Solo per i providers out-of-process (StateServer SQLServer) Usa GZipStream Riduzione fino a 2/3 della dimensione iniziale Implica un overhead ad ogni request (tradeoffs?)

» Programmatic activation Abilita/Disabilita l’uso della sessione (per request) HttpModule + SetSessionStateBehavior()

Page 26: ASP.NET 4.0

www.xedotnet.org 2617/01/2008

Session in ASP.net 4.0

DEMO

Page 27: ASP.NET 4.0

OutputCache extensibility

» OutputCache (da sempre!) Disponibile per WebForm & MVC (action filters) Aumenta drasticamente le prestazioni Consente di memorizzare la Response di

Pagine intere UserControls .ascx (fragment cache)

» Output Cache (da ASP.net 4.0) Disk-based & AppFabric providers (post-RTM) Estendibile/Personalizzabile

1. Implementare OutputCacheProvider (abstract class)2. Dichiarare il provider (web.config)3. Override GetOutputCacheProviderName (global.asax)

Page 28: ASP.NET 4.0

www.xedotnet.org 2817/01/2008

OutputCache extensibility

DEMO

Page 29: ASP.NET 4.0

Links

» IIS7.5 WarmupModule• http://www.iis.net/expand/applicationwarmup

» AppFabric• http://msdn.microsoft.com/en-us/windowsserver/ee695849.aspx• http://blogs.ugidotnet.org/AndreaCol/category/3613.aspx

» ASP.net 4.0 Routing• http://www.4guysfromrolla.com/articles/012710-1.aspx• SmartyRoute - http://bit.ly/PRA6G

» Try ASP.net 4.0 & one-click deploy (free)• http://labs.discountasp.net/• http://www.orcsweb.com/hosting/vs2010beta.aspx• http://aspnet4beta.maximumasp.com/

Page 30: ASP.NET 4.0

www.xedotnet.org 30

blog:

email:

web:

twitter:

Link

17/01/2008

Click icon to add picture

»Riferimenti

Blogs.ugidotnet.org/AndreaCol

[email protected]

www.andreacol.net

AndreaColaci