SlideShare a Scribd company logo
1 of 22
Download to read offline
Page Life
Cycle And
ViewState

Presenter: Vijay Goyal, Mindfire Solutions
Skype: mfsi_vijayg
Date: 30/09/2013
Agenda Of The Seminar
-

Pre Page Life Cyle (Asp.Net Inside IIS)
What on Earth is ViewState?
The different (Important) stages of Life Cycle
Where ViewState comes into the picture?
Dynamically created control
Deal with the burden of ViewState on the page
Some Demo...with some more Demo

Conferrer: Vijay Goyal, Mindfire Solutions
This is not an IIS course

Conferrer: Vijay Goyal, Mindfire Solutions
The Two Important Services

Conferrer: Vijay Goyal, Mindfire Solutions
The ProcessRequest()
- After all the registered
Modules are executed. The
page is ready to be served.
- For this IIS uses the
handler's mapping, to map
the request to the
appropriate handler.
- ProcessRequest() method is
executed and Page Life Cycle
begins

Conferrer: Vijay Goyal, Mindfire Solutions.
The Page Life Cycle Begins..

Conferrer: Vijay Goyal, Mindfire Solutions
Formation Of Control Heirarchy
- Request to an aspx page is served by a compiled
class

“C:WindowsMicrosoft.NETFrameworkv4.0.30319Temp
orary ASP.NET Files”
- Initializes the page's control hierarchy

Conferrer: Vijay Goyal, Mindfire Solutions
Formation Of Control Heirarchy

Conferrer: Vijay Goyal, Mindfire Solutions
But What's ViewState??
-

Its a misunderstood topic
An object of Statebag class
Stores changes done programatically
SelectedIndex / PageIndex not stored
A property of System.Web.UI.Controls
A key/value pair indexer.
Serialized to _VIEWSTATE hidden field
ViewState is a hungry beast.

Conferrer: Vijay Goyal, Mindfire Solutions
Initialization
- PreInit (Entry point, Non Recursive)
- Init (Tracking of Viewstate

is not enabled
/ Enabled for child controls, Recursive)

- InitComplete (Viewstate tracking
is turned on, Non Recursive)
- SaveViewState()
- Page.TrackViewState()
Conferrer: Vijay Goyal, Mindfire Solutions.
Load ViewState/Page Data
- Invoked only on Postbacks
- LoadControlState (Introduced in Asp.Net 2.0,
gridview page control, SaveControlState()l)

- LoadViewState
SaveViewState())

- LoadPostData

(Page and controls restored,

(Controls implement IpostBackDataHandler,

Selected value in dropdown, checkbox, Textbox)

Conferrer: Vijay Goyal, Mindfire Solutions.
Loading the Page...
- PreLoad (Non Recursive, End of Viewstate data load)
- Load (Top down approach, Previous State is fully loaded)
- RaisePostDataChangeEvent

(Controls implement
IpostBackDataHandler, TextChanged/SelectedIndexChanged)

- RaisePostBackEvent
click event)

- LoadComplete

(Controls implement IpostBackDataHandler,

(Page only)

Conferrer: Vijay Goyal, Mindfire Solutions
Page Rendering
- PreRender

(Recursive, Last update before the page is rendered)

- PreRenderComplete
view state is saved.)

(last event before the page's

- SaveControlState
- SaveViewState

(Control/Viewstate data are serialized to _VIEWSTATE)

- Render and Unload

(Renders the html to Client, Final Cleanup,closing
db, finishing up logging..etc)

Conferrer: Vijay Goyal, Mindfire Solutions
A Scenario

Conferrer: Vijay Goyal, Mindfire Solutions
Dynamically Added Controls
- They are not part of the compiled class
- Should be added in every page execution
- Plays catchup

(go thru all the page life cycle events of their own, Before
Page Render)

- Recommended to call in PreInit or Init, before tracking is
enabled

Conferrer: Vijay Goyal, Mindfire Solutions
Abbreviating ViewState
- Disable ViewState
- System.Web.UI.LosFormatter

(Limited Object Serialization)

- Compress/Decompress

(SavePageStateToPersistenceMedium,
LoadPageStateFromPersistenceMedium)

- Store in an external file

(Use SessionId/ GUID)

- Others... (Flesk.ViewStateOptimizer)
Conferrer: Vijay Goyal, Mindfire Solutions
Security??
- ViewState Decoder (a nice tool created by Fritz Onion).
- EnableViewStateMac
- ViewStateEncryptionMode

(Always/Auto , control calls
Page.RegisterRequiresViewStateEncryption() /Never)

Conferrer: Vijay Goyal, Mindfire Solutions
Prevent Tampering

Conferrer: Vijay Goyal, Mindfire Solutions
Prevent Tampering

Conferrer: Vijay Goyal, Mindfire Solutions
Here and there...
Machine.Config file <machineKey validation="SHA1"
validationKey="F3690E7A3143C185AB1089616A8B4D81FD55DD7A69EEAA3B32A6AE
813ECEECD28DEA66A23BEE42193729BD48595EBAFE2C2E765BE77E006330BC3B139
2D7C73F" DecryptionKey =” ” />
-

Local Security Authority Subsystem Service component

- References
http://msdn.microsoft.com/en-us/library/ff649308.aspx
http://msdn.microsoft.com/en-us/library/ms178472.aspx
http://pluralsight.com

Conferrer: Vijay Goyal, Mindfire Solutions
Conferrer: Vijay Goyal, Mindfire Solutions
Presenter: Vijay Goyal, Mindfire Solutions

More Related Content

What's hot

M S Ajax Client Life Cycle Events
M S  Ajax  Client  Life  Cycle  EventsM S  Ajax  Client  Life  Cycle  Events
M S Ajax Client Life Cycle Events
51 lecture
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routing
Brajesh Yadav
 

What's hot (20)

ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
 
Life cycle of web page
Life cycle of web pageLife cycle of web page
Life cycle of web page
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
Intro to ReactJS
Intro to ReactJSIntro to ReactJS
Intro to ReactJS
 
Building Modern Web Applications using React and Redux
 Building Modern Web Applications using React and Redux Building Modern Web Applications using React and Redux
Building Modern Web Applications using React and Redux
 
M S Ajax Client Life Cycle Events
M S  Ajax  Client  Life  Cycle  EventsM S  Ajax  Client  Life  Cycle  Events
M S Ajax Client Life Cycle Events
 
React outbox
React outboxReact outbox
React outbox
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
Redux Universal
Redux UniversalRedux Universal
Redux Universal
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
 
As pnet pagelife_usha
As pnet pagelife_ushaAs pnet pagelife_usha
As pnet pagelife_usha
 
Getting Started With ReactJS
Getting Started With ReactJSGetting Started With ReactJS
Getting Started With ReactJS
 
Grails Connecting to MySQL
Grails Connecting to MySQLGrails Connecting to MySQL
Grails Connecting to MySQL
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routing
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Using redux
Using reduxUsing redux
Using redux
 
Introduction to react js
Introduction to react jsIntroduction to react js
Introduction to react js
 

Viewers also liked

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Khaled Musaied
 
Custom controls
Custom controlsCustom controls
Custom controls
aspnet123
 

Viewers also liked (20)

ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Introduction to ASP.Net Viewstate
Introduction to ASP.Net ViewstateIntroduction to ASP.Net Viewstate
Introduction to ASP.Net Viewstate
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net Developer
 
ASP.NET - Web Programming
ASP.NET - Web ProgrammingASP.NET - Web Programming
ASP.NET - Web Programming
 
Asp.Net Control Architecture
Asp.Net Control ArchitectureAsp.Net Control Architecture
Asp.Net Control Architecture
 
User server interaction
User server interactionUser server interaction
User server interaction
 
Introducing asp.net web pages 2
Introducing asp.net web pages 2Introducing asp.net web pages 2
Introducing asp.net web pages 2
 
Directives in asp.net
Directives in asp.netDirectives in asp.net
Directives in asp.net
 
State management
State managementState management
State management
 
Custom controls
Custom controlsCustom controls
Custom controls
 
Asp.net server control
Asp.net  server controlAsp.net  server control
Asp.net server control
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
State Management In ASP.NET And ASP.NET MVC
State Management In ASP.NET And ASP.NET MVCState Management In ASP.NET And ASP.NET MVC
State Management In ASP.NET And ASP.NET MVC
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
 
Ch3 server controls
Ch3 server controlsCh3 server controls
Ch3 server controls
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 

Similar to ASP.NET Page life cycle and ViewState

Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
santoshkjogalekar
 
Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle events
Trushant parkar
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
Mahmoud Hamed Mahmoud
 
AnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior CreativelyAnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior Creatively
Kiana Tennyson
 
Week7 Dreamweaver Behavior & Image Hotspots
Week7 Dreamweaver Behavior & Image HotspotsWeek7 Dreamweaver Behavior & Image Hotspots
Week7 Dreamweaver Behavior & Image Hotspots
Rowena LI
 

Similar to ASP.NET Page life cycle and ViewState (20)

Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
 
Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle events
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in details
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?
 
Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Thinking metrics on React apps
Thinking metrics on React appsThinking metrics on React apps
Thinking metrics on React apps
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
 
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
MVP Community Camp 2014 - How to useenhanced features of Windows 8.1 Store ...MVP Community Camp 2014 - How to useenhanced features of Windows 8.1 Store ...
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
 
Hybrid App using WordPress
Hybrid App using WordPressHybrid App using WordPress
Hybrid App using WordPress
 
The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid Applications
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
 
Reactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsReactive state management with Jetpack Components
Reactive state management with Jetpack Components
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
A test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobileA test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobile
 
Building Testable Reactive Apps with MVI
Building Testable Reactive Apps with MVIBuilding Testable Reactive Apps with MVI
Building Testable Reactive Apps with MVI
 
Android Oreo
Android OreoAndroid Oreo
Android Oreo
 
AnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior CreativelyAnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior Creatively
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Week7 Dreamweaver Behavior & Image Hotspots
Week7 Dreamweaver Behavior & Image HotspotsWeek7 Dreamweaver Behavior & Image Hotspots
Week7 Dreamweaver Behavior & Image Hotspots
 

More from Mindfire Solutions

More from Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

ASP.NET Page life cycle and ViewState

  • 1. Page Life Cycle And ViewState Presenter: Vijay Goyal, Mindfire Solutions Skype: mfsi_vijayg Date: 30/09/2013
  • 2. Agenda Of The Seminar - Pre Page Life Cyle (Asp.Net Inside IIS) What on Earth is ViewState? The different (Important) stages of Life Cycle Where ViewState comes into the picture? Dynamically created control Deal with the burden of ViewState on the page Some Demo...with some more Demo Conferrer: Vijay Goyal, Mindfire Solutions
  • 3. This is not an IIS course Conferrer: Vijay Goyal, Mindfire Solutions
  • 4. The Two Important Services Conferrer: Vijay Goyal, Mindfire Solutions
  • 5. The ProcessRequest() - After all the registered Modules are executed. The page is ready to be served. - For this IIS uses the handler's mapping, to map the request to the appropriate handler. - ProcessRequest() method is executed and Page Life Cycle begins Conferrer: Vijay Goyal, Mindfire Solutions.
  • 6. The Page Life Cycle Begins.. Conferrer: Vijay Goyal, Mindfire Solutions
  • 7. Formation Of Control Heirarchy - Request to an aspx page is served by a compiled class “C:WindowsMicrosoft.NETFrameworkv4.0.30319Temp orary ASP.NET Files” - Initializes the page's control hierarchy Conferrer: Vijay Goyal, Mindfire Solutions
  • 8. Formation Of Control Heirarchy Conferrer: Vijay Goyal, Mindfire Solutions
  • 9. But What's ViewState?? - Its a misunderstood topic An object of Statebag class Stores changes done programatically SelectedIndex / PageIndex not stored A property of System.Web.UI.Controls A key/value pair indexer. Serialized to _VIEWSTATE hidden field ViewState is a hungry beast. Conferrer: Vijay Goyal, Mindfire Solutions
  • 10. Initialization - PreInit (Entry point, Non Recursive) - Init (Tracking of Viewstate is not enabled / Enabled for child controls, Recursive) - InitComplete (Viewstate tracking is turned on, Non Recursive) - SaveViewState() - Page.TrackViewState() Conferrer: Vijay Goyal, Mindfire Solutions.
  • 11. Load ViewState/Page Data - Invoked only on Postbacks - LoadControlState (Introduced in Asp.Net 2.0, gridview page control, SaveControlState()l) - LoadViewState SaveViewState()) - LoadPostData (Page and controls restored, (Controls implement IpostBackDataHandler, Selected value in dropdown, checkbox, Textbox) Conferrer: Vijay Goyal, Mindfire Solutions.
  • 12. Loading the Page... - PreLoad (Non Recursive, End of Viewstate data load) - Load (Top down approach, Previous State is fully loaded) - RaisePostDataChangeEvent (Controls implement IpostBackDataHandler, TextChanged/SelectedIndexChanged) - RaisePostBackEvent click event) - LoadComplete (Controls implement IpostBackDataHandler, (Page only) Conferrer: Vijay Goyal, Mindfire Solutions
  • 13. Page Rendering - PreRender (Recursive, Last update before the page is rendered) - PreRenderComplete view state is saved.) (last event before the page's - SaveControlState - SaveViewState (Control/Viewstate data are serialized to _VIEWSTATE) - Render and Unload (Renders the html to Client, Final Cleanup,closing db, finishing up logging..etc) Conferrer: Vijay Goyal, Mindfire Solutions
  • 14. A Scenario Conferrer: Vijay Goyal, Mindfire Solutions
  • 15. Dynamically Added Controls - They are not part of the compiled class - Should be added in every page execution - Plays catchup (go thru all the page life cycle events of their own, Before Page Render) - Recommended to call in PreInit or Init, before tracking is enabled Conferrer: Vijay Goyal, Mindfire Solutions
  • 16. Abbreviating ViewState - Disable ViewState - System.Web.UI.LosFormatter (Limited Object Serialization) - Compress/Decompress (SavePageStateToPersistenceMedium, LoadPageStateFromPersistenceMedium) - Store in an external file (Use SessionId/ GUID) - Others... (Flesk.ViewStateOptimizer) Conferrer: Vijay Goyal, Mindfire Solutions
  • 17. Security?? - ViewState Decoder (a nice tool created by Fritz Onion). - EnableViewStateMac - ViewStateEncryptionMode (Always/Auto , control calls Page.RegisterRequiresViewStateEncryption() /Never) Conferrer: Vijay Goyal, Mindfire Solutions
  • 18. Prevent Tampering Conferrer: Vijay Goyal, Mindfire Solutions
  • 19. Prevent Tampering Conferrer: Vijay Goyal, Mindfire Solutions
  • 20. Here and there... Machine.Config file <machineKey validation="SHA1" validationKey="F3690E7A3143C185AB1089616A8B4D81FD55DD7A69EEAA3B32A6AE 813ECEECD28DEA66A23BEE42193729BD48595EBAFE2C2E765BE77E006330BC3B139 2D7C73F" DecryptionKey =” ” /> - Local Security Authority Subsystem Service component - References http://msdn.microsoft.com/en-us/library/ff649308.aspx http://msdn.microsoft.com/en-us/library/ms178472.aspx http://pluralsight.com Conferrer: Vijay Goyal, Mindfire Solutions
  • 21. Conferrer: Vijay Goyal, Mindfire Solutions
  • 22. Presenter: Vijay Goyal, Mindfire Solutions