How to use application state in asp.net

How to use application state
ApplicationState.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        int counter = 0;
        if(Application["ButtonClickCounter"] !=null)
        {
            counter = (int)Application["ButtonClickCounter"];
        }
        counter++;
        Application["ButtonClickCounter"] = counter;
        Label1.Text = "Button Clicked: " + counter.ToString() + " times";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net application state example: how to use application state in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">asp.net application state example</h2>
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson">
        </asp:Label>
        <br /><br />
        <asp:Button 
            ID="Button1" 
            runat="server" 
            Text="Show Button Click Status"
            OnClick="Button1_Click"
            Font-Bold="true"
            ForeColor="SeaGreen"
            />
    </div>
    </form>
</body>
</html>


More asp.net examples