Solved

How to retrieve an instance of HttpApplicationState

Posted on 2008-06-16
3
1,356 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 earned 500 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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