Solved

How to retrieve an instance of HttpApplicationState

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

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:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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