SlideShare a Scribd company logo
State  management in ASP .NET
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Week Target Achieved
1 30 27
2 30 28
3
Typing Speed
Jobs Applied
# Company Designation Applied Date Current Status
1
2
3
State Management
Name
@gmail.com
www.facebook.com/userna
me
twitter.com/username
in.linkedin.com/in/profilena
me
Phonenumber
Why is state necessary?
• The vast majority of Internet applications
operate using the HTTP protocol.
• HTTP is state less.
– This means that each request for a page is treated
as a new request by the server.
Introduction to State Management
• Remember that ASP.NET is stateless
– The Web server does not keep track of past client
requests
• Different technologies handle the issue of
statement management differently
– ASP.NET is quite unique in this regard
Types of State Management
• ASP.NET offers two categories of state
management
– Pure client-side statement management
– Server-side state management
Client State Management
• View state
• Control state
• Hidden fields
• Cookies
• Query strings
State Management
(ViewState)
• ASP.NET preserves the state of the page’s controls between
post backs by packaging and encoding it within a hidden
html field.
• This view state feature can also be used programmatically to
preserve additional information between post backs for the
same page
Eg :- ViewState["RequestCount"] = count;
int count = (int)ViewState["RequestCount"];
Advantages & Disadvantage of
View State
• It consumes no server memory.
• It is more hidden than Query String and Hidden
Fields
• Its possible to encrypt View State information.
Disadvantage :-
– It increases the size of the page.
State Management
(ControlState)
• The ControlState property allows you to
persist information as like the view state.
– The ControlState data is stored in hidden
fields.
Control State Application
• If we create a custom control that requires
view state to work properly.
• We should use control state to ensure other
developers don’t break your control by
disabling view state.
State Management
(Hidden Fields)
• Use the HiddenField control to store
persisted data.
• The data is stored in the Value property
• It’s simple and requires no server resources
State Management
(Query Strings)
• A query string can be used to submit data
back to the same page or to another page
through the URL.
Eg :-
string url = "productPage.aspx?id=" + id;
Response.Redirect(url);
productPage.aspx
int id = Convert.ToInt32(Request*"id“+);
Disadvantages of Query String
• Not secured (its visible completely in the
address bar to the users)
• The maximum allowable length of a query
string varies from browser to browser(IE only
allows only 2k of url)
State Management
(Cookies)
• Cookies are a client-side approach for
persisting state information.
• These pairs accompany both server requests
and responses within the HTTP header
• Eg:-
HttpCookie cookie = new HttpCookie("Name",txtName.Text);
// Set expiry date to 1 day, 12 hours from now
cookie.Expires = DateTime.Now + new TimeSpan(1, 12, 0, 0);
Response.Cookies.Add(cookie);
Cookie Limitations
• While simple, cookies have disadvantages
• A cookie can only be 4096 bytes in size
• Most browsers restrict the total number of
cookies per site
• Users can refuse to accept cookies so don’t try
to use them to store critical information
Server State Management
• Application state
• Session state
Session state
• Session state is a server-based state
mechanism that allows you to store data in a
dictionary-style collection.
• It is scoped to the current browser session.
• That is, each user or browser session has a
different session state.
Example
• session*“uname”+=txt_uname.text;
String uname=session*“uname”+.Tostring();
Application state
• Application state is a server-stored state
mechanism that allows you to store global
data in a dictionary-style collection that is
accessible from all pages in the Web
application.
Application state
• Thus, application state is ideal for storing
relatively small, frequently used sets of data
that do not change from user-to-user or
request to request.
• Eg :-
Application["SiteRequestCount"] = 0;
int count = (int)Application["SiteRequestCount";
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

More Related Content

What's hot (19)

PPTX
Chapter 8 part1
application developer
 
PPTX
C# cookieless session id and application state
Malav Patel
 
PPS
05 asp.net session07
Mani Chaubey
 
PPT
Servers names
Sasidhar Kothuru
 
PPTX
ASP.NET Lecture 4
Julie Iskander
 
PPTX
Session 30 - Servlets - Part 6
PawanMM
 
PPTX
Session 29 - Servlets - Part 5
PawanMM
 
PPTX
Session 39 - Hibernate - Part 1
PawanMM
 
DOCX
State management servlet
Thakur Amit Tomer
 
PPT
Session viii(state mngtserver)
Shrijan Tiwari
 
PPTX
01 session tracking
dhrubo kayal
 
PPTX
Using cookies and sessions
Nuha Noor
 
PPTX
Query Store and live Query Statistics
SolidQ
 
PPTX
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
PawanMM
 
PPSX
06 asp.net session08
Vivek Singh Chandel
 
PPT
Sql Server Security
Vinod Kumar
 
PPTX
Session And Cookies In Servlets - Java
JainamParikh3
 
Chapter 8 part1
application developer
 
C# cookieless session id and application state
Malav Patel
 
05 asp.net session07
Mani Chaubey
 
Servers names
Sasidhar Kothuru
 
ASP.NET Lecture 4
Julie Iskander
 
Session 30 - Servlets - Part 6
PawanMM
 
Session 29 - Servlets - Part 5
PawanMM
 
Session 39 - Hibernate - Part 1
PawanMM
 
State management servlet
Thakur Amit Tomer
 
Session viii(state mngtserver)
Shrijan Tiwari
 
01 session tracking
dhrubo kayal
 
Using cookies and sessions
Nuha Noor
 
Query Store and live Query Statistics
SolidQ
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
PawanMM
 
06 asp.net session08
Vivek Singh Chandel
 
Sql Server Security
Vinod Kumar
 
Session And Cookies In Servlets - Java
JainamParikh3
 

Viewers also liked (20)

PPTX
ASP.NET State management
Shivanand Arur
 
PPTX
State management
Iblesoft
 
PPTX
Introduction to asp.net
Melick Baranasooriya
 
PPTX
State management in ASP.net
baabtra.com - No. 1 supplier of quality freshers
 
PPT
ASP.NET Tutorial - Presentation 1
Kumar S
 
PPT
Asp.net.
Naveen Sihag
 
PPT
As pnet pagelife_usha
Rajalaxmi Pattanaik
 
PDF
Asp.net caching
Mindfire Solutions
 
PPT
Aspnet Caching
rainynovember12
 
PPTX
Asp.net presentation by gajanand bohra
Gajanand Bohra
 
PPTX
Presentation on asp.net controls
Reshi Unen
 
PPTX
Asp Net Advance Topics
Ali Taki
 
PPT
Asp.net
Dinesh kumar
 
PPTX
Web forms in ASP.net
Madhuri Kavade
 
PPT
Concepts of Asp.Net
vidyamittal
 
PPT
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
PPTX
ASP.NET Presentation
dimuthu22
 
ASP.NET State management
Shivanand Arur
 
State management
Iblesoft
 
Introduction to asp.net
Melick Baranasooriya
 
ASP.NET Tutorial - Presentation 1
Kumar S
 
Asp.net.
Naveen Sihag
 
As pnet pagelife_usha
Rajalaxmi Pattanaik
 
Asp.net caching
Mindfire Solutions
 
Aspnet Caching
rainynovember12
 
Asp.net presentation by gajanand bohra
Gajanand Bohra
 
Presentation on asp.net controls
Reshi Unen
 
Asp Net Advance Topics
Ali Taki
 
Asp.net
Dinesh kumar
 
Web forms in ASP.net
Madhuri Kavade
 
Concepts of Asp.Net
vidyamittal
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
ASP.NET Presentation
dimuthu22
 
Ad

Similar to State management in ASP .NET (20)

PPT
StateManagement in ASP.Net.ppt
charusharma165
 
PPTX
State management in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
State Management.pptx
DrMonikaPatel2
 
PDF
state management asp.net
Pratiksha Srivastava
 
PDF
Asp.net state management
priya Nithya
 
DOC
State management in asp
Ibrahim MH
 
PPTX
State management
Muhammad Amir
 
PPTX
Session and cookies,get and post
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Managing state in asp.net
Sireesh K
 
PPS
05 asp.net session07
Niit Care
 
PPT
Session viii(state mngtclient)
Shrijan Tiwari
 
PPT
ASP.NET 12 - State Management
Randy Connolly
 
PPTX
81.pptx ajx fyjc semester paper 2 parrtens
epfoportal69
 
PPT
2310 b 14
Krazy Koder
 
PPT
state managment
aniliimd
 
PPTX
ASP.NET Lecture 2
Julie Iskander
 
DOCX
Managing states
Paneliya Prince
 
PPTX
Chapter 8 part2
application developer
 
PPTX
Sessions&cookies
Tirthika Bandi
 
StateManagement in ASP.Net.ppt
charusharma165
 
State Management.pptx
DrMonikaPatel2
 
state management asp.net
Pratiksha Srivastava
 
Asp.net state management
priya Nithya
 
State management in asp
Ibrahim MH
 
State management
Muhammad Amir
 
Session and cookies,get and post
baabtra.com - No. 1 supplier of quality freshers
 
Managing state in asp.net
Sireesh K
 
05 asp.net session07
Niit Care
 
Session viii(state mngtclient)
Shrijan Tiwari
 
ASP.NET 12 - State Management
Randy Connolly
 
81.pptx ajx fyjc semester paper 2 parrtens
epfoportal69
 
2310 b 14
Krazy Koder
 
state managment
aniliimd
 
ASP.NET Lecture 2
Julie Iskander
 
Managing states
Paneliya Prince
 
Chapter 8 part2
application developer
 
Sessions&cookies
Tirthika Bandi
 
Ad

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
PDF
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 

Recently uploaded (20)

PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
epi editorial commitee meeting presentation
MIPLM
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
infertility, types,causes, impact, and management
Ritu480198
 
Horarios de distribución de agua en julio
pegazohn1978
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 

State management in ASP .NET

  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Week Target Achieved 1 30 27 2 30 28 3 Typing Speed
  • 4. Jobs Applied # Company Designation Applied Date Current Status 1 2 3
  • 6. Why is state necessary? • The vast majority of Internet applications operate using the HTTP protocol. • HTTP is state less. – This means that each request for a page is treated as a new request by the server.
  • 7. Introduction to State Management • Remember that ASP.NET is stateless – The Web server does not keep track of past client requests • Different technologies handle the issue of statement management differently – ASP.NET is quite unique in this regard
  • 8. Types of State Management • ASP.NET offers two categories of state management – Pure client-side statement management – Server-side state management
  • 9. Client State Management • View state • Control state • Hidden fields • Cookies • Query strings
  • 10. State Management (ViewState) • ASP.NET preserves the state of the page’s controls between post backs by packaging and encoding it within a hidden html field. • This view state feature can also be used programmatically to preserve additional information between post backs for the same page Eg :- ViewState["RequestCount"] = count; int count = (int)ViewState["RequestCount"];
  • 11. Advantages & Disadvantage of View State • It consumes no server memory. • It is more hidden than Query String and Hidden Fields • Its possible to encrypt View State information. Disadvantage :- – It increases the size of the page.
  • 12. State Management (ControlState) • The ControlState property allows you to persist information as like the view state. – The ControlState data is stored in hidden fields.
  • 13. Control State Application • If we create a custom control that requires view state to work properly. • We should use control state to ensure other developers don’t break your control by disabling view state.
  • 14. State Management (Hidden Fields) • Use the HiddenField control to store persisted data. • The data is stored in the Value property • It’s simple and requires no server resources
  • 15. State Management (Query Strings) • A query string can be used to submit data back to the same page or to another page through the URL. Eg :- string url = "productPage.aspx?id=" + id; Response.Redirect(url); productPage.aspx int id = Convert.ToInt32(Request*"id“+);
  • 16. Disadvantages of Query String • Not secured (its visible completely in the address bar to the users) • The maximum allowable length of a query string varies from browser to browser(IE only allows only 2k of url)
  • 17. State Management (Cookies) • Cookies are a client-side approach for persisting state information. • These pairs accompany both server requests and responses within the HTTP header • Eg:- HttpCookie cookie = new HttpCookie("Name",txtName.Text); // Set expiry date to 1 day, 12 hours from now cookie.Expires = DateTime.Now + new TimeSpan(1, 12, 0, 0); Response.Cookies.Add(cookie);
  • 18. Cookie Limitations • While simple, cookies have disadvantages • A cookie can only be 4096 bytes in size • Most browsers restrict the total number of cookies per site • Users can refuse to accept cookies so don’t try to use them to store critical information
  • 19. Server State Management • Application state • Session state
  • 20. Session state • Session state is a server-based state mechanism that allows you to store data in a dictionary-style collection. • It is scoped to the current browser session. • That is, each user or browser session has a different session state.
  • 22. Application state • Application state is a server-stored state mechanism that allows you to store global data in a dictionary-style collection that is accessible from all pages in the Web application.
  • 23. Application state • Thus, application state is ideal for storing relatively small, frequently used sets of data that do not change from user-to-user or request to request. • Eg :- Application["SiteRequestCount"] = 0; int count = (int)Application["SiteRequestCount";
  • 24. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 25. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: [email protected]