aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

What is an application object and where we use application object in | application object sample using

Oct 18, 2011

In this article I will explain what application object is and I will explain how we will use application objects in


Today I am writing this post to explain about application object in In one of the interview I got question like what application object is and where we will use application object in

What is an application object?

Application object is used to store the information and access variables from any page in application. Application object is same as session object only the difference is session object is used to maintain the session for particular user. If one user enters in to the application then session id will create for that particular user if he leaves from the application then the session id will deleted. If they again enter in to the application they will get different session id but application object is same for all users once application object is created that application object is used throughout the application regardless of user. The information stored in application object accessed throughout all the pages in application (like database connection information) and we can change the application object in one place those changes automatically reflected in all the pages.

You can create application objects in Global.asax file and access those variables throughout the application. To know about how to add Global.asax file check the post here

Add following code in Global.asax file like this

<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
// Code that runs on application startup
Application["UserID"] = "SureshDasari";
After completion of writing code global.asax file write the following code in aspx page

<title>Application Object Sample</title> 
<form id="form1" runat="server"> 
<asp:Label id="lblText" runat="server"></asp:Label> 
After that write the following code in code behind like this

public void Page_Load(object sender, EventArgs e)
this.lblText.Text =  "UserName: " + Application["UserID"] + "<br>";

Now run your application you will see the application object value in your page. I hope it helps you. 

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


sarabose said...
This comment has been removed by a blog administrator.
Dheeraj Bansal said...

Hi Suresh

I am really a great fan of your blog.
I just want to ask one question. How to compress Whole directory or folder in
Thanks in advance.

Dheeraj Bansal

karunasri said...

hi suresh
thank u

Anonymous said...


vengalreddy said...

tanks a lot suresh garu....

hareesh arava said...

very impressive article suresh


neeraj(lilu) said...

thanks for suggestion this gives me help .......

Anonymous said...

thanks for the tip...good one

Anonymous said...

GOOD one.more impresive

Anonymous said...

amazing blogs yaar...

Raj said...

Love you yaar .. Tanx for ur Blog... really its so valuable for me

Raj said...

Love you yaar .. Tanx for ur Blog... really its so valuable for me

Anonymous said...

Good job for valuable information.


Meeru telugu varu anukunta... me post lu chala baguntai andi....chala usefull posts inka simple ga arthamayye posts pedataru meeru...Dhanyavadalu...

parthiban said...

Its really nice got more ideas...........

parthiban said...

More valuable for beginners...............

Anonymous said...

thanks alot ....

Anonymous said...

Nice Article Buddy

Jhansi said...

Hi Suresh,

Can you tell me when will the application objects be cleared? I mean every time we execute the application will they be reset to the initial value?

Give your Valuable Comments

Other Related Posts

© 2010-2012 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.