Solved

How to retrieve an instance of HttpApplicationState

Posted on 2008-06-16
3
1,339 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
3 Comments
 

Expert Comment

by:mjhoagland
Comment Utility
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
Comment Utility
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
Comment Utility
Seems simple enough. I can just refer to HttpContext.Current.Application whenever I need the instance. Thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now