Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 67449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:15:41+00:00 2026-05-10T19:15:41+00:00

I have a web application that makes heavy use of the Session state to

  • 0

I have a web application that makes heavy use of the Session state to store information about the current user, their personal settings, record their session history and so on.

I have found myself retrieving this session information in my business layer, like so:

((UserSession)HttpContext.Current.Session['UserSession']).User.Info 

This poses a problem – at some point in the future my application will have a Windows client which obviously cannot reference the web Session state. So I need a host or customized session class that I can reference in my business layer that is agnostic of whether the application is running on the web or desktop. Something like:

IHost.User.Info 

Behind the scenes, the web implementation will obviously utilize the Session state to store information, but I need to hide this away from my business layer. Has anyone solved this problem or got any practival advice on how best to approach this?

Help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:15:42+00:00Added an answer on May 10, 2026 at 7:15 pm

    Assuming that the business layer is a separate DLL, I would never add a reference to System.Web and in consequence I would never use the Session object directly. This would lead to a different design of the business layer and of the exposed interfaces to a client (either web or winforms).

    That said, as a quick workaround I would suggest to write a wrapper class in your business layer that hides the Session object from your code. Your calls from code will be something like this:

    ((UserSession) DualContext.Current['UserSession']).User.Info 

    and the wrapper implementation will be something like this (not completed and tested):

    public class DualContext  {    private Dictionary<string, object> winFormsSession = new Dictionary<string, object>();    private static readonly DualContext instance = new DualContext();     public static DualContext Current    {       get {  return instance; }    }     public object this[string key]    {       get        {          if (HttpContext.Current != null)             return HttpContext.Current.Session[key];          else             return winFormsSession[key];       }       set        {          if (HttpContext.Current != null)             HttpContext.Current.Session[key] = value;          else             winFormsSession[key] = value;       }    } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .net web application that makes heavy use of oracle stored procedures.
I have am working on a web application that makes use of helper classes.
we have an asp.net application, that makes heavy use of REST/json services through httpwebrequest
I have an ASP .NET Web Forms application that makes use of the 'WebMethod'
I'm developing an application that makes heavy use of web services. I will be
I've recently inherited an application that makes very heavy use of session, including storing
I have a web application that makes use of a Spring TaskExecutor. The task
I am designing a Java web application that makes heavy use of AJAX (for
I have a certain web application that makes upwards of ~100 updates to an
I have a web application that uses two databases. DB1 Users perform their CRUD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.