Solved

How to retrieve an instance of HttpApplicationState

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

25 Experts available now in Live!

Get 1:1 Help Now