ASP.NET 4.0
-
Upload
xedotnet -
Category
Technology
-
view
2.301 -
download
2
Transcript of ASP.NET 4.0
![Page 1: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/1.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/2.jpg)
» 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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/3.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/4.jpg)
Granular ViewState
@Page EnableViewState=False
Control1 ViewStateMode=Enabled
![Page 5: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/7.jpg)
www.xedotnet.org 717/01/2008
VS2010, Granular ViewState, ControlId
DEMO
![Page 8: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/10.jpg)
Routing != URL Rewriting
![Page 11: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/11.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/12.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/13.jpg)
www.xedotnet.org 1317/01/2008
Routing
DEMO
![Page 14: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/14.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/16.jpg)
Web deployment
» Pages» Content» IIS Settings» Database Schema + Data + Custom
Scripts
![Page 17: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/17.jpg)
www.xedotnet.org 1717/01/2008
Web.config transform, one-click deployment
DEMO
![Page 18: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/18.jpg)
www.xedotnet.org 1817/01/2008
PARTE 2: RUNTIME
![Page 19: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/19.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/20.jpg)
www.xedotnet.org 2017/01/2008
ARM AppDomain Resource Monitoring
DEMO
![Page 21: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/21.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/22.jpg)
IProcessHostPreloadClient
AppPool
Consumer App
Business App
Cache Custom Warm-up code IProcessHostPreloadClient
Data Store
Request
Request
Request
![Page 23: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/23.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/24.jpg)
www.xedotnet.org 2417/01/2008
IIS 7.5 integration & warm-up
DEMO
![Page 25: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/25.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/26.jpg)
www.xedotnet.org 2617/01/2008
Session in ASP.net 4.0
DEMO
![Page 27: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/27.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/28.jpg)
www.xedotnet.org 2817/01/2008
OutputCache extensibility
DEMO
![Page 29: ASP.NET 4.0](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/29.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062220/55526699b4c905d41d8b5043/html5/thumbnails/30.jpg)
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