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 9289657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:14:03+00:00 2026-06-18T20:14:03+00:00

In a ASP.NET WebApi hosted in IIS 7, does it have access to session?

  • 0

In a ASP.NET WebApi hosted in IIS 7, does it have access to session? It appears Session is null on the HttpContext.Current.

What is the difference between these two for storing a global variable?

private static Dictionary<string, string> ConnectionStrings
    {
        get
        {
            if (HttpContext.Current.Session["ConnectionStrings"] == null)
                HttpContext.Current.Session["ConnectionStrings"] = new Dictionary<string, string>();

            return HttpContext.Current.Session["ConnectionStrings"] as Dictionary<string, string>;
        }
    }

and

private static Dictionary<string, string> connectionStrings = new Dictionary<string, string>();

Should I use session or static variables to store connection strings that are dynamically generated (long story)?

  • 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. Editorial Team
    Editorial Team
    2026-06-18T20:14:04+00:00Added an answer on June 18, 2026 at 8:14 pm

    Well, a session variable is meant to be per user. A static variable is a variable that will be shared between all users. So, I have no idea why would store a connection string per user, but if you need to do that, you can’t use one static variable. Now, you could use a static variable and make it a Dictionary, where the key is the user, and the value is whatever you want to store. That would certainly work.

    Having said all that, you can mimic sessions using cookies (which ultimately is what sessions make use of anyway (usually)): See: Accessing Session Using ASP.NET Web API

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Asp.net WebAPI service that is hosted on AppHarbor which throws 404
ASP.NET WebAPI's can either hosted within IIS (as a web role) or be self
I have an ASP .Net MVC 3.0 web application hosted on IIS and I
I have developed a self hosted asp.net webapi service that uses basic authentication using
I have a layered web application that I built with ASP.NET MVC 4, WebAPI
Using ASP.NET MVC4 I have created a DelegatingHandler in a WebAPI project. I use
We have an IIS 7.5 with the following site structure: WebApp (ASP.NET Forms) =
I have created a file upload method using ASP.NET WEBAPI, below the code: [DataContract]
I have a developed a Restful webservice using Asp.net WebAPI and used the windows
I have an ASP.NET WebApi project that utilizes Entity Framework 4.1. I am attempting

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.