SlideShare a Scribd company logo
โ€ข Session State Configuration
โ€ข Session Modes in ASP.NET
    ๏ƒผ InProc
    ๏ƒผ StateServer
    ๏ƒผ SQLServer
    ๏ƒผ Custom
โ€ข Application State
โ€ข An Overview of State Management Choices
You configure session state through the web.config file.
The configuration file allows you to set advanced options
such as the timeout and the session state mode.

<sessionState
cookieless="UseCookies"
cookieName="ASP.NET_SessionId"
regenerateExpiredSessionId="false"
timeout="20"
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeout="10"
sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
sqlCommandTimeout="30"
allowCustomSqlDatabase="false"
customProvider=""
compressionEnabled="false"/>
You can set the cookieless setting to one of the values
defined by the HttpCookieMode enumeration,
This specifies the number of minutes that ASP.NET will
wait, without receiving a request, before it abandons the
session.

You can also programmatically change the session
timeout in code. For example, if you know a
session contains an unusually large amount of
information, you may need to limit the amount of time
the session can be stored.

Session.Timeout = 10;
In ASP.NET, there are the following session modes
available:

InProc : It instructs session state information to be
stored in the application domain
StateServer : With this setting, ASP.NET will use a
separate Windows service called StateServer for state
management.
SQLServer : This setting instructs ASP.NET to use an
SQL Server database to store session information
Custom : This setting use custom or third-party(e.g
Oracle) provider to store state information
Off : This setting disables session state management
InProc is the default mode. It instructs information to
be stored in the applicationโ€™s domain, or in the main
ASP.NET process, which provides the best
performance but the least durability.

If you restart your server, the state information will be
lost.

In ASP.NET, application domains can be restarted for
a variety of reasons, including configuration changes
and updated pages, and when certain thresholds are
met.
With this setting, ASP.NET will use a separate
ASP.NET State Service for state management.

This service runs on the same web server, but itโ€™s
outside the main ASP.NET process, which gives it a
basic level of protection if the ASP.NET process needs
to be restarted.

When using the StateServer setting, you need to
specify a value for the stateConnectionString.

This string identifies the TCP/IP address of the
computer that is running the StateServer service
and its port number.

For local server it is 127.0.0.1.
Use the Microsoft Management Console (MMC).

1. Select Start โžค Control Panel.
2. Open the Administrative Tools group, and then choose
    Computer Management.
3. In the Computer Management tool, go to the Services
    and Applications โžค Services node.
4. Find ASP.NET State Service in the list
5. You can manually start and stop the service by right-
    clicking it. Select Properties, and modify the Startup
    Type to Automatic to automatically start the service.

When using StateServer mode, you can also set an
optional stateNetworkTimeout attribute that specifies the
maximum number of seconds to wait for the service to
respond before canceling the request.
This setting instructs ASP.NET to use an SQL Server
database to store session information, as identified
by the sqlConnectionString attribute.

This is the most resilient state store but also the
slowest by far.

To use this method of state management, youโ€™ll need
to have a server with SQL Server installed.

In addition, you need to install the special stored
procedures and temporary session databases.

These stored procedures take care of storing and
retrieving the session information.
ASP.NET includes a command-line tool called
aspnet_regsql.exe to install session storage
database on the current computer, and gives
default database name ASPState.

The easiest way to run aspnet_regsql.exe is to
open the Start menu and choose Programs โžค
Visual Studio 2010 โžค Visual Studio Tools โžค Visual
Studio Command Prompt.

The command that creates the session storage
database ASPState on the current computer is:

aspnet_regsql.exe -S localhost -E โ€“ssadd
If youโ€™re using a database named ASPState to store your
session information (which is the default), you donโ€™t need to
supply the database name. Simply indicate the location of the
server and the type of authentication that ASP.NET should use
in the web.config file

<sessionState mode="SQLServer"
sqlConnectionString="data source=127.0.0.1;Integrated
Security=SSPIโ€œ ... />

When using the SQLServer mode, you can also set an optional
sqlCommandTimeout attribute that specifies the maximum
number of seconds to wait for the database to respond before
canceling the request.
When using custom mode, you need to indicate which
session state store provider to use by supplying
the customProvider attribute which indicates the name of
the class.

The class may be part of your web application (in which
case the source code is placed in the App_Code
subfolder), or it can be in an assembly that your web
application is using (in which case the compiled
assembly is placed in the Bin subfolder)

Other vendors may release custom state providers you
want to use. For example, Oracle could provide a custom
state provider that allows you to store state information in
an Oracle database
The enableCompression setting only has an effect when
youโ€™re using out-of-process session state storage.

When you set enableCompression to true, session data is
compressed before itโ€™s passed out of the application domain.

There are two key scenarios where session state
compression makes sense:

โ€ข   When the out-of-process state server is hogging a lot of memory
โ€ข   When storing session state data on another computer
Application state allows you to store global objects that
can be accessed by any client.

The command to create Application variable:
Application["HitCounterForOrderPage"] = count;

// to retrieve an Application variable

int count = 0;
if (Application["HitCounterForOrderPage"] != null)
{
count = (int)Application["HitCounterForOrderPage"];
}
Application state isnโ€™t often used, because itโ€™s generally
inefficient.

Because two clients can access an application variable
at the same time, you need to use the Application.Lock()
and Application.Unlock() methods, which explicitly allow
only one client to access the Application state collection
at a time.
Application state is rarely used in the .NET world because its
two most common uses have been replaced by easier, more
efficient methods:

โ€ข In the past, application state was used to store application-
  wide constants, such as a database connection string
  which can be stored in the web.config file

โ€ข Application state can also be used to store frequently used
  information that is time-consuming to create. It can be
   replaced more efficiently with caching.
Chapter 8   part2
Ad

More Related Content

What's hot (17)

Odi 11g master and work repository creation steps
Odi 11g master and work repository creation stepsOdi 11g master and work repository creation steps
Odi 11g master and work repository creation steps
Dharmaraj Borse
ย 
Less12 3 e_loadmodule_2
Less12 3 e_loadmodule_2Less12 3 e_loadmodule_2
Less12 3 e_loadmodule_2
Suresh Mishra
ย 
Sql server lesson11
Sql server lesson11Sql server lesson11
Sql server lesson11
Ala Qunaibi
ย 
Sql server lesson12
Sql server lesson12Sql server lesson12
Sql server lesson12
Ala Qunaibi
ย 
Deploy agent in em12c
Deploy agent in em12cDeploy agent in em12c
Deploy agent in em12c
Osama Mustafa
ย 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
Dharmaraj Borse
ย 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy Queries
Chema Alonso
ย 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
Pragya Rastogi
ย 
Installing ingres enterprise access in a system which already has an ingres i...
Installing ingres enterprise access in a system which already has an ingres i...Installing ingres enterprise access in a system which already has an ingres i...
Installing ingres enterprise access in a system which already has an ingres i...
malu42
ย 
Introduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQLIntroduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQL
Frans Jongma
ย 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
Sisir Ghosh
ย 
Concepts of NonStop SQL/MX: Part 5 - Stored Procedures
Concepts of NonStop SQL/MX: Part 5 - Stored ProceduresConcepts of NonStop SQL/MX: Part 5 - Stored Procedures
Concepts of NonStop SQL/MX: Part 5 - Stored Procedures
Frans Jongma
ย 
Plsql
PlsqlPlsql
Plsql
Nst Tnagar
ย 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
ย 
Chapter 5
Chapter 5Chapter 5
Chapter 5
application developer
ย 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
Shivanand Arur
ย 
Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crud
Parakram Chavda
ย 
Odi 11g master and work repository creation steps
Odi 11g master and work repository creation stepsOdi 11g master and work repository creation steps
Odi 11g master and work repository creation steps
Dharmaraj Borse
ย 
Less12 3 e_loadmodule_2
Less12 3 e_loadmodule_2Less12 3 e_loadmodule_2
Less12 3 e_loadmodule_2
Suresh Mishra
ย 
Sql server lesson11
Sql server lesson11Sql server lesson11
Sql server lesson11
Ala Qunaibi
ย 
Sql server lesson12
Sql server lesson12Sql server lesson12
Sql server lesson12
Ala Qunaibi
ย 
Deploy agent in em12c
Deploy agent in em12cDeploy agent in em12c
Deploy agent in em12c
Osama Mustafa
ย 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
Dharmaraj Borse
ย 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy Queries
Chema Alonso
ย 
Installing ingres enterprise access in a system which already has an ingres i...
Installing ingres enterprise access in a system which already has an ingres i...Installing ingres enterprise access in a system which already has an ingres i...
Installing ingres enterprise access in a system which already has an ingres i...
malu42
ย 
Introduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQLIntroduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQL
Frans Jongma
ย 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
Sisir Ghosh
ย 
Concepts of NonStop SQL/MX: Part 5 - Stored Procedures
Concepts of NonStop SQL/MX: Part 5 - Stored ProceduresConcepts of NonStop SQL/MX: Part 5 - Stored Procedures
Concepts of NonStop SQL/MX: Part 5 - Stored Procedures
Frans Jongma
ย 
Plsql
PlsqlPlsql
Plsql
Nst Tnagar
ย 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
Shivanand Arur
ย 
Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crud
Parakram Chavda
ย 

Viewers also liked (9)

Chapter 23
Chapter 23Chapter 23
Chapter 23
application developer
ย 
Chapter 25
Chapter 25Chapter 25
Chapter 25
application developer
ย 
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di SangiranSejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
latifanajla
ย 
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
KetiGjipali
ย 
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
่‡บ็ฃๅก”็ฑณๆญ
ย 
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผWF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
่‡บ็ฃๅก”็ฑณๆญ
ย 
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
่‡บ็ฃๅก”็ฑณๆญ
ย 
Next step job board (Assignment)
Next step job board (Assignment)Next step job board (Assignment)
Next step job board (Assignment)
application developer
ย 
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di SangiranSejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
Sejarah Indonesia Kelas X - Analisis Temuan Fosil di Sangiran
latifanajla
ย 
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
โ€œQendรซr pรซr tรซ moshuarโ€ (Plan Biznesi)
KetiGjipali
ย 
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
ๆˆ‘่ฆๆ€Ž้บผ่จญๅฎšWF2409ไธ€ๅ€‹็„ก็ทšๅŸบๅœฐๅฐ็ตฆ่‡ชๅทฑ็”จ๏ผŒๅฆไธ€ๅ€‹็ตฆ่จชๅฎข็”จ๏ผŒ่ฎ“่จชๅฎข็”จ็š„็ถฒ่ทฏไธๆœƒๅฝฑ้Ÿฟๅ…ง้ƒจ็ถฒ่ทฏ
่‡บ็ฃๅก”็ฑณๆญ
ย 
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผWF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
WF2409ๅฆ‚ไฝ•่จญๅฎš็„ก็ทšไธญ็นผ
่‡บ็ฃๅก”็ฑณๆญ
ย 
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
WF2409่ฆๅฆ‚ไฝ•reset(ๅฎŒๅ…จๆขๅพฉๅŽŸๅป ้ ่จญๅ€ผ)
่‡บ็ฃๅก”็ฑณๆญ
ย 
Next step job board (Assignment)
Next step job board (Assignment)Next step job board (Assignment)
Next step job board (Assignment)
application developer
ย 
Ad

Similar to Chapter 8 part2 (20)

05 asp.net session07
05 asp.net session0705 asp.net session07
05 asp.net session07
Vivek Singh Chandel
ย 
05 asp.net session07
05 asp.net session0705 asp.net session07
05 asp.net session07
Mani Chaubey
ย 
Session viii(state mngtserver)
Session viii(state mngtserver)Session viii(state mngtserver)
Session viii(state mngtserver)
Shrijan Tiwari
ย 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Vivek Singh Chandel
ย 
State management
State managementState management
State management
teach4uin
ย 
2310 b 14
2310 b 142310 b 14
2310 b 14
Krazy Koder
ย 
Sql saturday oc 2019
Sql saturday oc 2019Sql saturday oc 2019
Sql saturday oc 2019
SitotpalSarkar
ย 
Less13 3 e_loadmodule_3
Less13 3 e_loadmodule_3Less13 3 e_loadmodule_3
Less13 3 e_loadmodule_3
Suresh Mishra
ย 
Asp.net
Asp.netAsp.net
Asp.net
Yaswanth Babu Gummadivelli
ย 
Sql storeprocedure
Sql storeprocedureSql storeprocedure
Sql storeprocedure
ftz 420
ย 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
Amin Uddin
ย 
StateManagement in ASP.Net.ppt
StateManagement in ASP.Net.pptStateManagement in ASP.Net.ppt
StateManagement in ASP.Net.ppt
charusharma165
ย 
ASP.NET 12 - State Management
ASP.NET 12 - State ManagementASP.NET 12 - State Management
ASP.NET 12 - State Management
Randy Connolly
ย 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Mani Chaubey
ย 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
LiquidHub
ย 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
aspnet123
ย 
Pre Install Databases
Pre Install DatabasesPre Install Databases
Pre Install Databases
LiquidHub
ย 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3
Neeraj Mathur
ย 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
MahmoudOHassouna
ย 
E catt tutorial
E catt tutorialE catt tutorial
E catt tutorial
Naveen Raj
ย 
05 asp.net session07
05 asp.net session0705 asp.net session07
05 asp.net session07
Mani Chaubey
ย 
Session viii(state mngtserver)
Session viii(state mngtserver)Session viii(state mngtserver)
Session viii(state mngtserver)
Shrijan Tiwari
ย 
State management
State managementState management
State management
teach4uin
ย 
2310 b 14
2310 b 142310 b 14
2310 b 14
Krazy Koder
ย 
Sql saturday oc 2019
Sql saturday oc 2019Sql saturday oc 2019
Sql saturday oc 2019
SitotpalSarkar
ย 
Less13 3 e_loadmodule_3
Less13 3 e_loadmodule_3Less13 3 e_loadmodule_3
Less13 3 e_loadmodule_3
Suresh Mishra
ย 
Sql storeprocedure
Sql storeprocedureSql storeprocedure
Sql storeprocedure
ftz 420
ย 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
Amin Uddin
ย 
StateManagement in ASP.Net.ppt
StateManagement in ASP.Net.pptStateManagement in ASP.Net.ppt
StateManagement in ASP.Net.ppt
charusharma165
ย 
ASP.NET 12 - State Management
ASP.NET 12 - State ManagementASP.NET 12 - State Management
ASP.NET 12 - State Management
Randy Connolly
ย 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Mani Chaubey
ย 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
LiquidHub
ย 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
aspnet123
ย 
Pre Install Databases
Pre Install DatabasesPre Install Databases
Pre Install Databases
LiquidHub
ย 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3
Neeraj Mathur
ย 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
MahmoudOHassouna
ย 
E catt tutorial
E catt tutorialE catt tutorial
E catt tutorial
Naveen Raj
ย 
Ad

More from application developer (20)

Chapter 26
Chapter 26Chapter 26
Chapter 26
application developer
ย 
Chapter 19
Chapter 19Chapter 19
Chapter 19
application developer
ย 
Chapter 18
Chapter 18Chapter 18
Chapter 18
application developer
ย 
Chapter 17
Chapter 17Chapter 17
Chapter 17
application developer
ย 
Chapter 16
Chapter 16Chapter 16
Chapter 16
application developer
ย 
Week 3 assignment
Week 3 assignmentWeek 3 assignment
Week 3 assignment
application developer
ย 
Chapter 15
Chapter 15Chapter 15
Chapter 15
application developer
ย 
Chapter 14
Chapter 14Chapter 14
Chapter 14
application developer
ย 
Chapter 13
Chapter 13Chapter 13
Chapter 13
application developer
ย 
Chapter 12
Chapter 12Chapter 12
Chapter 12
application developer
ย 
Chapter 11
Chapter 11Chapter 11
Chapter 11
application developer
ย 
Chapter 10
Chapter 10Chapter 10
Chapter 10
application developer
ย 
C # test paper
C # test paperC # test paper
C # test paper
application developer
ย 
Chapter 9
Chapter 9Chapter 9
Chapter 9
application developer
ย 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
application developer
ย 
Chapter 7
Chapter 7Chapter 7
Chapter 7
application developer
ย 
Chapter 6
Chapter 6Chapter 6
Chapter 6
application developer
ย 
Week 1 Assignment Q2 Solution
Week 1 Assignment Q2 SolutionWeek 1 Assignment Q2 Solution
Week 1 Assignment Q2 Solution
application developer
ย 
Week 1 assignment q2
Week 1 assignment q2Week 1 assignment q2
Week 1 assignment q2
application developer
ย 
Week 1 Assignment Q1 Solution
Week 1 Assignment Q1 SolutionWeek 1 Assignment Q1 Solution
Week 1 Assignment Q1 Solution
application developer
ย 

Recently uploaded (20)

Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
ย 

Chapter 8 part2

  • 1. โ€ข Session State Configuration โ€ข Session Modes in ASP.NET ๏ƒผ InProc ๏ƒผ StateServer ๏ƒผ SQLServer ๏ƒผ Custom โ€ข Application State โ€ข An Overview of State Management Choices
  • 2. You configure session state through the web.config file. The configuration file allows you to set advanced options such as the timeout and the session state mode. <sessionState cookieless="UseCookies" cookieName="ASP.NET_SessionId" regenerateExpiredSessionId="false" timeout="20" mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" stateNetworkTimeout="10" sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI" sqlCommandTimeout="30" allowCustomSqlDatabase="false" customProvider="" compressionEnabled="false"/>
  • 3. You can set the cookieless setting to one of the values defined by the HttpCookieMode enumeration,
  • 4. This specifies the number of minutes that ASP.NET will wait, without receiving a request, before it abandons the session. You can also programmatically change the session timeout in code. For example, if you know a session contains an unusually large amount of information, you may need to limit the amount of time the session can be stored. Session.Timeout = 10;
  • 5. In ASP.NET, there are the following session modes available: InProc : It instructs session state information to be stored in the application domain StateServer : With this setting, ASP.NET will use a separate Windows service called StateServer for state management. SQLServer : This setting instructs ASP.NET to use an SQL Server database to store session information Custom : This setting use custom or third-party(e.g Oracle) provider to store state information Off : This setting disables session state management
  • 6. InProc is the default mode. It instructs information to be stored in the applicationโ€™s domain, or in the main ASP.NET process, which provides the best performance but the least durability. If you restart your server, the state information will be lost. In ASP.NET, application domains can be restarted for a variety of reasons, including configuration changes and updated pages, and when certain thresholds are met.
  • 7. With this setting, ASP.NET will use a separate ASP.NET State Service for state management. This service runs on the same web server, but itโ€™s outside the main ASP.NET process, which gives it a basic level of protection if the ASP.NET process needs to be restarted. When using the StateServer setting, you need to specify a value for the stateConnectionString. This string identifies the TCP/IP address of the computer that is running the StateServer service and its port number. For local server it is 127.0.0.1.
  • 8. Use the Microsoft Management Console (MMC). 1. Select Start โžค Control Panel. 2. Open the Administrative Tools group, and then choose Computer Management. 3. In the Computer Management tool, go to the Services and Applications โžค Services node. 4. Find ASP.NET State Service in the list 5. You can manually start and stop the service by right- clicking it. Select Properties, and modify the Startup Type to Automatic to automatically start the service. When using StateServer mode, you can also set an optional stateNetworkTimeout attribute that specifies the maximum number of seconds to wait for the service to respond before canceling the request.
  • 9. This setting instructs ASP.NET to use an SQL Server database to store session information, as identified by the sqlConnectionString attribute. This is the most resilient state store but also the slowest by far. To use this method of state management, youโ€™ll need to have a server with SQL Server installed. In addition, you need to install the special stored procedures and temporary session databases. These stored procedures take care of storing and retrieving the session information.
  • 10. ASP.NET includes a command-line tool called aspnet_regsql.exe to install session storage database on the current computer, and gives default database name ASPState. The easiest way to run aspnet_regsql.exe is to open the Start menu and choose Programs โžค Visual Studio 2010 โžค Visual Studio Tools โžค Visual Studio Command Prompt. The command that creates the session storage database ASPState on the current computer is: aspnet_regsql.exe -S localhost -E โ€“ssadd
  • 11. If youโ€™re using a database named ASPState to store your session information (which is the default), you donโ€™t need to supply the database name. Simply indicate the location of the server and the type of authentication that ASP.NET should use in the web.config file <sessionState mode="SQLServer" sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPIโ€œ ... /> When using the SQLServer mode, you can also set an optional sqlCommandTimeout attribute that specifies the maximum number of seconds to wait for the database to respond before canceling the request.
  • 12. When using custom mode, you need to indicate which session state store provider to use by supplying the customProvider attribute which indicates the name of the class. The class may be part of your web application (in which case the source code is placed in the App_Code subfolder), or it can be in an assembly that your web application is using (in which case the compiled assembly is placed in the Bin subfolder) Other vendors may release custom state providers you want to use. For example, Oracle could provide a custom state provider that allows you to store state information in an Oracle database
  • 13. The enableCompression setting only has an effect when youโ€™re using out-of-process session state storage. When you set enableCompression to true, session data is compressed before itโ€™s passed out of the application domain. There are two key scenarios where session state compression makes sense: โ€ข When the out-of-process state server is hogging a lot of memory โ€ข When storing session state data on another computer
  • 14. Application state allows you to store global objects that can be accessed by any client. The command to create Application variable: Application["HitCounterForOrderPage"] = count; // to retrieve an Application variable int count = 0; if (Application["HitCounterForOrderPage"] != null) { count = (int)Application["HitCounterForOrderPage"]; }
  • 15. Application state isnโ€™t often used, because itโ€™s generally inefficient. Because two clients can access an application variable at the same time, you need to use the Application.Lock() and Application.Unlock() methods, which explicitly allow only one client to access the Application state collection at a time.
  • 16. Application state is rarely used in the .NET world because its two most common uses have been replaced by easier, more efficient methods: โ€ข In the past, application state was used to store application- wide constants, such as a database connection string which can be stored in the web.config file โ€ข Application state can also be used to store frequently used information that is time-consuming to create. It can be replaced more efficiently with caching.