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)?