Skip Navigation LinksHome > Categories > Code from a Category

What is an application object and where we use application object in ASP.Net



User Name: codelecturer
Name: Mike Chauhan
Contact Me: www.datawebcoder.com/ContactUs.aspx
Home Page: www.datawebcoder.com
6 years of total IT experience including programming, application development, System Maintenance . 3 years of Experienced and expertise in .Net Framework VB, Visual Basic.Net, ASP.Net 2.0, 3.5 and AD... [More]
Viewed Times: 2078
Add Date: 11/09/2011
Here, I will explain what application object is and explain how we will use application objects in ASP.Net.
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
]]>
After completion of writing code global.asax file write the following code in aspx page

After that write the following code in code behind like this

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

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Details**:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
 
    
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.