在 IIS 7 中托管的 ASP.NET WebApi 中,它是否有权访问会话?它似乎Session
在HttpContext.Current
.
这两者用于存储全局变量有什么区别?
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>();
我应该使用会话变量还是静态变量来存储动态生成的连接字符串(长篇大论)?