1. ASP.NET Introduction 2. Comp of .Net Framework 3.5 3. Sys.Req for VS 2008 4. ASP.NET Envrmnt Setup 5. VS2010 Ultimate Sys.Req 6. Installing VS 2010 7. VS 2012 Sys.Req 8. Installing VS Exp 2012 9. Start the VS 2008 10. Application Life Cycle 11. Page Life Cycle 12. Page Life Cycle Events 13. ASP.NET Example 14. Event Handling 15. Default Events 16. Server Side 17. Request Object 18. Response Object 19. Server Controls 20. Server Controls Properties 21. Server Controls Methods 22. HTML Server Controls 23. Client Side 24. ASP.NET Basic Controls 25. TextBox Control 26. CheckBox Controls 27. RadioButton Controls 28. ListBox Control 29. HyperLink Control 30. Image Control 31. BulletedList Control 32. ASP.NET Directives 33. Implements Directive 34. Master Type Directive 35. Page Directive 36. PreviousPage Type 37. Managing State 38. Control State 39. Cookies 40. Query Strings 41. Server-Side State 42. Session State 43. Validation Controls 44. Required FieldValidator 45. Range Validator 46. Compare Validator 47. RegularExpressionValidator 48. Custom Validator 49. Validation Summary 50. Data Source Control 51. AdRotator Control 52. Calendar Control 53. Calendar Control Example 54. Panel Control 55. Panel Control Example 56. Multi Views Control 57. MultiView & View controls 58. MultiView Control Example 59. FileUpload Control 60. FileUpload Control Eg 61. AJAX Control 62. UpdatePanel control 63. UpdateProgress Control 64. Custom Controls 65. Custom Control Eg 66. Personalization 67. Create Simple Profile 68. ADO.NET 69. ADO.NET Objects 70. DataTable 71. DataRow 72. DataColumn 73. Object Example 74. Error Handling 75. Tracing Errors 76. Debugger 77. Security 78. Authentication 79. Authorization 80. LINQ 81. LINQ Query Operators 82. LINQ Example 83. Caching 84. Data Caching 85. Output Caching 86. Object Caching 87. Web Services 88. Create Web Services Eg 89. Web & Machine.config 90. Settings Schema 91. ASP.NET Deployment 92. XCopy Deployment 93. Web Setup Project 94. ASP Interview Part 1 95. ASP Interview Part 2 96. ASP Interview Part 3 97. ASP Interview Part 4 98. ASP Interview Part 5 99. ASP Interview Part 6
Pr.Pg Next Pg

Server-Side State Management tutorials

  • Server-side options for storing page information typically have higher security than client-side options, but they can use more Web server resources, which can lead to scalability issues when the size of the information store is large. ASP.NET provides several options to implement server-side state management. 

  • The following are the server-side state management that ASP.NET supports:

    1. Application State

    2. Session State


Application State

  • Application state is used to store data which is visible across entire application and shared across multiple user sessions. Data which needs to be persisted for entire life of application should be stored in application object.

  • In classic ASP, application state is used to store connection strings. It's a great place to store data which changes infrequently. We should write to application variable only in application_Onstart event (global.asax) or application.lock event to avoid data conflicts.

  • There are three types of Application events in ASP.NET

    1. Application_start: The Application_Start event is raised when an app domain starts. When the first request is raised to an application then the Application_Start event is raised.

    2. Application_End: The Application_End event is raised just before an application domain ends because of any reason, may IIS server restarting or making some changes in an application cycle.   

    3. Application_Error: It is raised when an unhandled exception occurs, and we can manage the exception in this event.

  • Advantages of using application state are:
    1. Simple implementation: Application state is easy to use, familiar to ASP developers, and consistent with other .NET Framework classes.

    2. Application scope: Because application state is accessible to all pages in an application, storing information in application state can mean keeping only a single copy of the information (for instance, as opposed to keeping copies of information in session state or in individual pages).

  • Disadvantages of using application state are:

    1. The scope of application state can also be a disadvantage. Variables stored in application state are global only to the particular process the application is running in, and each application process can have different values. Therefore, you cannot rely on application state to store unique values or update global counters in Web-garden and Web-farm server configurations.

    2. Limited durability of data: Because global data that is stored in application state is volatile, it will be lost if the Web server process containing it is destroyed, such as from a server crash, upgrade, or shutdown.

    3. Resource requirements: Application state requires server memory, which can affect the performance of the server as well as the scalability of the application.

  • Example: Here we have craeted Application state in the Global.asax page. Where the application USERID is Jack, and application PASSWORD is jack@123.
  • Global.asax file: The Global.asax file is an optional file used to declare and handle application and session-level events and objects for an ASP.NET web site running on an IIS Web Server.



Following example shows the use of ASP.NET Application State(Server-Side State Management)Creating Application State in the Global.asax file:

Sam Sir


<%@ Application Language="C#" %>


<script runat="server">


void Application_Start(object sender, EventArgs e)


// Code that runs on application startup

Application["UserID"] = "Jack";

Application["Password"] = "jack@123";



void Application_End(object sender, EventArgs e)


// Code that runs on application shutdown



void Application_Error(object sender, EventArgs e)


// Code that runs when an unhandled error occurs



void Session_Start(object sender, EventArgs e)


// Code that runs when a new session is started



void Session_End(object sender, EventArgs e)


// Code that runs when a session ends.

// Note: The Session_End event is raised only when the sessionstate mode

// is set to InProc in the Web.config file. If session mode is set to StateServer

// or SQLServer, the event is not raised. 





Default.aspx.cs Code:


Following example shows the use of ASP.NET Application State(Server-Side State Management): Creating Application State in the .aspx.cs file:

Sam Sir


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class _Default : System.Web.UI.Page


protected void Page_Load(object sender, EventArgs e)



protected void TextBox2_TextChanged(object sender, EventArgs e)




protected void Button1_Click(object sender, EventArgs e)


Session["UserID"] = UserID.Text;

Session["Password"] = Password.Text;

string user = (string)Application["UserID"];

string password=(string)Application["Password"];

if (UserID.Text == user && Password.Text == password)


Out.Text = "Welcome "+UserID.Text;




Out.Text = "Sorry User Name or Password is incorrect.";






Default.aspx Code:


Following example shows the use of ASP.NET Application State(Server-Side State Management): Creating Application State in the .aspx file:

Sam Sir


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head runat="server">




<form id="form1" runat="server">


<asp:Label ID="Label1" runat="server" Text="UserID"></asp:Label>

:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="UserID" runat="server"></asp:TextBox><br />

<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>:

<asp:TextBox ID="Password" runat="server" ontextchanged="TextBox2_TextChanged"

TextMode="Password"></asp:TextBox><br />


<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />


<asp:Label ID="Out" runat="server"></asp:Label>





output server side example server side example


Pr.Pg border                                              Next Pg