asp.net 4.0
TRANSCRIPT
In collaborazione con
ASP.net 4.0 WebForm and Core RuntimeLe novità per lo sviluppo web(Form) e del runtime
» Andrea Colaci
» 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
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
Granular ViewState
@Page EnableViewState=False
Control1 ViewStateMode=Enabled
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
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
www.xedotnet.org 717/01/2008
VS2010, Granular ViewState, ControlId
DEMO
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
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)
Routing != URL Rewriting
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
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
www.xedotnet.org 1317/01/2008
Routing
DEMO
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)
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
Web deployment
» Pages» Content» IIS Settings» Database Schema + Data + Custom
Scripts
www.xedotnet.org 1717/01/2008
Web.config transform, one-click deployment
DEMO
www.xedotnet.org 1817/01/2008
PARTE 2: RUNTIME
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
www.xedotnet.org 2017/01/2008
ARM AppDomain Resource Monitoring
DEMO
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
IProcessHostPreloadClient
AppPool
Consumer App
Business App
Cache Custom Warm-up code IProcessHostPreloadClient
Data Store
Request
Request
Request
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
www.xedotnet.org 2417/01/2008
IIS 7.5 integration & warm-up
DEMO
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()
www.xedotnet.org 2617/01/2008
Session in ASP.net 4.0
DEMO
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)
www.xedotnet.org 2817/01/2008
OutputCache extensibility
DEMO
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/
www.xedotnet.org 30
blog:
email:
web:
twitter:
Link
17/01/2008
Click icon to add picture
»Riferimenti
Blogs.ugidotnet.org/AndreaCol
www.andreacol.net
AndreaColaci