Click here to Skip to main content
13,301,105 members (57,560 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads


84 bookmarked
Posted 11 Nov 2012

State Management in ASP.NET - Introduction

, 20 Jan 2014
An overview of state management techniques in ASP.NET.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class sessionDemo : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (Request.QueryString["Count"] != null) //Lets retrieve, increase and store again
            Label3.Text = Request.QueryString["Count"];
    protected void Button2_Click(object sender, EventArgs e)
        int noOfRedirection = 0;

        if (Request.QueryString["Count"] != null) //Lets retrieve, increase and store again
            noOfRedirection = Convert.ToInt32(Request.QueryString["Count"]) + 1;
        else //First postback, lets store the info
            noOfRedirection = 1;

        Response.Redirect("sessionApplicationDemo.aspx?Count=" + noOfRedirection);
    protected void Button1_Click(object sender, EventArgs e)
        Application["Count"] = Convert.ToInt32(Application["Count"]) + 1;
        Label1.Text = Application["Count"].ToString();

        //Store in Session State --------------------------------------------------------------          
        Session["Count"] = Convert.ToInt32(Session["Count"]) + 1;
        Label2.Text = Session["Count"].ToString();


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sachin Gargava
Software Developer (Senior)
India India
He has done Master Degree in Computer Application (MCA) and currently working as a Sr. Software Engineer and having more than 6+ years exp. He has worked with all the .NET framework and good exposure in Web and Windows based development using Microsoft Technology.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 20 Jan 2014
Article Copyright 2012 by Sachin Gargava
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid