w3wp.exe Common Language Runtime (CLR) JIT compiler Garbage Collection threads mscoree.dll mscorsvr.dll MyApp.dll 20
Form: Code behind: Private Sub FileDropDownList_SelectedIndexChanged _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles FileDropDownList.SelectedIndexChanged Session("FileSelected") = FileDropDownList.SelectedValue End Sub 21
EventUsage PreInit Create dynamic controls, set the Theme; master page, etc. Init Read or initialize control properties InitComplete Raised by the Page object. PreLoad Perform any processing on your page or control before the Load event. Load The Page calls the OnLoad event method on the Page, then recursively for each child control and its children Control events Button Clicks and other Control events are processed after Page_Load LoadComplete Fires after all controls on the page are loaded. PreRender Data binding for controls occurs now. SaveStateComplete Fires when the ViewState for all controls is complete and saved. Render Method that writes out the html markup associated with the control. Unload Do final cleanup, such as closing files or database connections 42
State Management ViewState Stored in _VIEWSTATE hidden field ControlState Override if ViewState is turned off on the Page HiddenField control Cookies Add cookie data to the Cookies collection in the HttpResponse object Query strings Application State HttpApplicationState Session State Profiles SqlProfileProvider 47
53 ASP.NET Session state HttpContext.Session Data associated with a logical sequence of Requests that need to be persisted across interactions Unique session IDs are passed along automatically with each Request as either cookies or embedded in the URL Session data is stored in a Dictionary collection, allowing individual session state variables to be accessed directly by Key name Three external storage options InProc StateServer SQL Server Timeout management
54 HttpContext.Session InProc option provides fastest service, but does not permit access to Session data from a different process in a Web garden application or a different Web server in a cluster Using alternatives to InProc session storage has significant performance implications StateServer SQL Server Custom provider Measure impact using the IIS RequestNotification events e.g., AcquireRequestState, PostAcquireRequestState
86 BindingResponse Time (msecs)Throughput wsHttpBinding13001200 basicHttpBinding11501800 netTcpBinding4005100 netNamedPipeBinding2807000 Source: Resnik, Crane, & Bowen, Essential Windows Communication Foundation, Addison Wesley, 2008. Chapter 4. See also, “A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies”A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies Caution: your mileage will vary. Caution: your mileage will vary.