在IIS 7中托管的ASP.NET WebApi中,它是否可以访问会话?在HttpContext.Current上看起来Session是null.
这两个存储全局变量有什么区别?
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>; } }
和
private static Dictionary<string,string> connectionStrings = new Dictionary<string,string>();
我应该使用会话或静态变量来存储动态生成的连接字符串(长篇故事)吗?