Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to retrieve an instance of HttpApplicationState

Posted on 2008-06-16
3
Medium Priority
?
1,358 Views
Last Modified: 2013-12-17
I have been using the Application property of the System.Web.UI.Page class frequently. However, I want to centralize some of the functions that use this object in my Business Logic Layer which doesn't inherit from the System.Web.UI.Page class. How can I use this object in my Business Logic Layer class?
0
Comment
Question by:Russ Suter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:mjhoagland
ID: 21796717
You can pass it as a parameter to your business logic layer.  That way you can know the reference is always up to date.
0
 
LVL 27

Accepted Solution

by:
Sammy Ageil earned 2000 total points
ID: 21796750
try something like this
hope this helps

 public class myObject
    {
        public myObject()
        { }
        HttpApplicationState _appState = HttpContext.Current.Application;
      public  HttpApplicationState AppState
        {
            get { return _appState; }
            set { _appState = value; }
        }
    }
//Usage in any other page or Class
 myObject myObject = new myObject();
            myObject.AppState.Add("1", 1);

Open in new window

0
 
LVL 20

Author Closing Comment

by:Russ Suter
ID: 31467722
Seems simple enough. I can just refer to HttpContext.Current.Application whenever I need the instance. Thanks!
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question