SlideShare a Scribd company logo
1 of 29
Download to read offline
Welcome to my ppt
PRESENTATION ON STATE MANAGEMENT
IN ASP.NET
Q. WHAT IS STATE MANAGEMENT ?
State Management is very important feature in Asp.net .
State Management is a process by which state and page
information is maintained over multiple requests for same or
different pages.
State management maintains and stores the information of any
user till the end of the user session .
As HTTP is a stateless protocol ,server does not store any
information once the response is sent back to client based on his
request.
Web server does not have any idea about the requests.
When user submits request again, the server treats it as a new
user.
E.g. Online registration form.
So, to retain the values of the controls
we use state management techniques.
They are classified into the following
two categories :-
❖ Client side state management -
• Which Utilizes Client Resources
• Ways:View state , Control State,
Hidden Field State, Cookies,
Query Strings, Cache.
❖ Server side state management -
• Which Utilizes Server Resources
• Ways: Session State, Application
State
CLIENT SIDE STATE
MANAGEMENT
VIEW STATE
OR
Q. SIGNIFICANT OF VIEW STATE IN ASP.NET
Features of view state –
o Retains the value of the control after post-back without using a session.
o Stores the value of pages and control properties defined in the page.
o Creates a custom View State Provider that lets us store view state information in a
SQL server database or in another data store.
Advantages -
o Easy to Implement.
o No server resources are required.The View State is contained in a structure within the page
load.
o Enhanced security features: It can be encoded and compressed or Unicode implementation.
Disadvantages -
o Security risk
o Performance Consideration
o Device limitation
Example :
Q. WHAT IS QUERY STRING ?
o A Query String contains the information that is sent to server with URL.
o The URL part which comes after the ? Symbol is called QueryString.
o It has two parts , a key and a value. Like for E.G.- ?query=foo , here query is the
key and foo Is its value.
Advantages -
o It is very lightweight and will not consume any server resources.
o It is very easy to use and it is the most efficient state management
technique.
o Simple implementation.
Disadvantages -
o We can pass information only as a string.
o URL length has limitations. So we can’t send much information
through URL.
o Information passed is clearly visible to everyone and can be easily
altered/Potential Security Risk.
o Limited capacity
HIDDEN FIELDS
COOKIES
OR
Q. ROLE OF COOKIES IN ASP.NET
ASP.NET Cookie is a small bit of text that is used to store
user-specific information.
This information can be read by the web application whenever
user visits the site.
When a user requests for a web page, web server sends not just a
page, but also a cookie containing the date and time.
TYPES OF COOKIES
THERE ARE TWO TYPES OF COOKIES –
•Persist cookies
•Non-Persist cookies
❑ Persist Cookie
When cookies are saved within the browser’s temporary folder on the
client’s machine, such cookies are said to be persisted, because
information saved can be retrieved at any time, so long the cookies’
expiration date has not elapsed.
❑ Non-Persist
Cookies
Also known as session or in-memory cookies, these are only useable while
the browser is open.They are not saved locally on the client’s machine.
Advantages of Cookies -
o Its clear text so user can able to read it
o We can store user preference information on the client machine.
o Its easy way to maintain.
o Fast accessing.
Disadvantages of Cookies -
o If user clears cookie information we can't get it back.
o No security
o Each request will have cookie information with page.
protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie Username = new
HttpCookie("UserName","WELCOME");
Username.Expires=DateTime.Now.AddYears(1);
Response.Cookies.Add(Username);
}
Q.Write a program to create a new cookie with the name
“Username” and add it to the HTTP Response object on the click of
a button. Set the expiry date of the cookie to One year from Now.
❖ Code
SERVER SIDE STATE
MANAGEMENT
❖ SESSION STATE
• Stored in the server’s memory and value can be accessed across
page requests.
Advantages –
o Cookieless support
o Data persistence
Disadvantages –
o Performance Consideration
❖ APPLICATION STATE
o It is used to store global application specific information.
o Automatically created when a first request is made to a web application.
o Storing Application state in the server’s memory is better than storing the
information in the database.
o It is server side state management mechanism.
o The application state is used same as session, but the difference is, the
session state is specific for a single user; where as an application state is
common for all users.
Advantages
o Application scope
o Simple implementation
Disadvantages
o Requires server resources
o Limited durability of data (server cash or shutdown)
EXAMPLE -
HERE WE ARE GOING TO CALCULATE HOW MANY TIMES A
GIVEN PAGE HAS BEEN VISITED BY VARIOUS CLIENTS.
ASP.NET State Management Techniques for Beginners
ASP.NET State Management Techniques for Beginners
ASP.NET State Management Techniques for Beginners

More Related Content

Similar to ASP.NET State Management Techniques for Beginners

Job portal at jiit 2013-14
Job portal at jiit 2013-14Job portal at jiit 2013-14
Job portal at jiit 2013-14kbabhishek4
 
Documentation
DocumentationDocumentation
DocumentationKalyan A
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State managementShivanand Arur
 
Cache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure ApplicationsCache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure ApplicationsInterSystems Corporation
 
Lecture32-Web-based-testing-II.pptx
Lecture32-Web-based-testing-II.pptxLecture32-Web-based-testing-II.pptx
Lecture32-Web-based-testing-II.pptxBalkrishanpatidar
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 
E-Business And Technology Essay
E-Business And Technology EssayE-Business And Technology Essay
E-Business And Technology EssayPamela Wright
 
State management
State managementState management
State managementIblesoft
 

Similar to ASP.NET State Management Techniques for Beginners (20)

Job portal at jiit 2013-14
Job portal at jiit 2013-14Job portal at jiit 2013-14
Job portal at jiit 2013-14
 
Asp.net
Asp.netAsp.net
Asp.net
 
State management in ASP .NET
State  management in ASP .NETState  management in ASP .NET
State management in ASP .NET
 
Documentation
DocumentationDocumentation
Documentation
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
 
28791456 web-testing
28791456 web-testing28791456 web-testing
28791456 web-testing
 
OWASP Top 10 Proactive Control 2016 (C5-C10)
OWASP Top 10 Proactive Control 2016 (C5-C10)OWASP Top 10 Proactive Control 2016 (C5-C10)
OWASP Top 10 Proactive Control 2016 (C5-C10)
 
Cache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure ApplicationsCache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure Applications
 
Lecture32-Web-based-testing-II.pptx
Lecture32-Web-based-testing-II.pptxLecture32-Web-based-testing-II.pptx
Lecture32-Web-based-testing-II.pptx
 
Online Test Engine
Online  Test EngineOnline  Test Engine
Online Test Engine
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
E-Examination
E-ExaminationE-Examination
E-Examination
 
Job portal
Job portalJob portal
Job portal
 
E-Business And Technology Essay
E-Business And Technology EssayE-Business And Technology Essay
E-Business And Technology Essay
 
locker presentation (1)
locker presentation (1)locker presentation (1)
locker presentation (1)
 
Browser Based Performance Testing and Tuning
Browser Based Performance Testing and TuningBrowser Based Performance Testing and Tuning
Browser Based Performance Testing and Tuning
 
State management
State managementState management
State management
 
Ch7-Computer Security
Ch7-Computer SecurityCh7-Computer Security
Ch7-Computer Security
 
load_testing.ppt.pptx
load_testing.ppt.pptxload_testing.ppt.pptx
load_testing.ppt.pptx
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 

ASP.NET State Management Techniques for Beginners

  • 2. PRESENTATION ON STATE MANAGEMENT IN ASP.NET
  • 3. Q. WHAT IS STATE MANAGEMENT ? State Management is very important feature in Asp.net . State Management is a process by which state and page information is maintained over multiple requests for same or different pages. State management maintains and stores the information of any user till the end of the user session . As HTTP is a stateless protocol ,server does not store any information once the response is sent back to client based on his request. Web server does not have any idea about the requests. When user submits request again, the server treats it as a new user. E.g. Online registration form.
  • 4. So, to retain the values of the controls we use state management techniques. They are classified into the following two categories :- ❖ Client side state management - • Which Utilizes Client Resources • Ways:View state , Control State, Hidden Field State, Cookies, Query Strings, Cache. ❖ Server side state management - • Which Utilizes Server Resources • Ways: Session State, Application State
  • 6. VIEW STATE OR Q. SIGNIFICANT OF VIEW STATE IN ASP.NET
  • 7. Features of view state – o Retains the value of the control after post-back without using a session. o Stores the value of pages and control properties defined in the page. o Creates a custom View State Provider that lets us store view state information in a SQL server database or in another data store. Advantages - o Easy to Implement. o No server resources are required.The View State is contained in a structure within the page load. o Enhanced security features: It can be encoded and compressed or Unicode implementation. Disadvantages - o Security risk o Performance Consideration o Device limitation
  • 9.
  • 10. Q. WHAT IS QUERY STRING ? o A Query String contains the information that is sent to server with URL. o The URL part which comes after the ? Symbol is called QueryString. o It has two parts , a key and a value. Like for E.G.- ?query=foo , here query is the key and foo Is its value.
  • 11. Advantages - o It is very lightweight and will not consume any server resources. o It is very easy to use and it is the most efficient state management technique. o Simple implementation. Disadvantages - o We can pass information only as a string. o URL length has limitations. So we can’t send much information through URL. o Information passed is clearly visible to everyone and can be easily altered/Potential Security Risk. o Limited capacity
  • 12.
  • 13.
  • 14.
  • 16. COOKIES OR Q. ROLE OF COOKIES IN ASP.NET ASP.NET Cookie is a small bit of text that is used to store user-specific information. This information can be read by the web application whenever user visits the site. When a user requests for a web page, web server sends not just a page, but also a cookie containing the date and time.
  • 17. TYPES OF COOKIES THERE ARE TWO TYPES OF COOKIES – •Persist cookies •Non-Persist cookies
  • 18. ❑ Persist Cookie When cookies are saved within the browser’s temporary folder on the client’s machine, such cookies are said to be persisted, because information saved can be retrieved at any time, so long the cookies’ expiration date has not elapsed. ❑ Non-Persist Cookies Also known as session or in-memory cookies, these are only useable while the browser is open.They are not saved locally on the client’s machine.
  • 19. Advantages of Cookies - o Its clear text so user can able to read it o We can store user preference information on the client machine. o Its easy way to maintain. o Fast accessing. Disadvantages of Cookies - o If user clears cookie information we can't get it back. o No security o Each request will have cookie information with page.
  • 20. protected void Button1_Click(object sender, EventArgs e) { HttpCookie Username = new HttpCookie("UserName","WELCOME"); Username.Expires=DateTime.Now.AddYears(1); Response.Cookies.Add(Username); } Q.Write a program to create a new cookie with the name “Username” and add it to the HTTP Response object on the click of a button. Set the expiry date of the cookie to One year from Now. ❖ Code
  • 22. ❖ SESSION STATE • Stored in the server’s memory and value can be accessed across page requests.
  • 23. Advantages – o Cookieless support o Data persistence Disadvantages – o Performance Consideration
  • 24. ❖ APPLICATION STATE o It is used to store global application specific information. o Automatically created when a first request is made to a web application. o Storing Application state in the server’s memory is better than storing the information in the database. o It is server side state management mechanism. o The application state is used same as session, but the difference is, the session state is specific for a single user; where as an application state is common for all users.
  • 25. Advantages o Application scope o Simple implementation Disadvantages o Requires server resources o Limited durability of data (server cash or shutdown)
  • 26. EXAMPLE - HERE WE ARE GOING TO CALCULATE HOW MANY TIMES A GIVEN PAGE HAS BEEN VISITED BY VARIOUS CLIENTS.