Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1360
  • Last Modified:

How to retrieve an instance of HttpApplicationState

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
Russ Suter
Asked:
Russ Suter
1 Solution
 
mjhoaglandCommented:
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
 
Sammy AgeilCommented:
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
 
Russ SuterAuthor Commented:
Seems simple enough. I can just refer to HttpContext.Current.Application whenever I need the instance. Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now