6
在IIS 7中託管的ASP.NET WebApi中,它是否有權訪問會話?在HttpContext.Current
上看起來Session
爲空。ASP.NET WebApi會話與靜態變量
這兩個存儲全局變量有什麼區別?
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>();
我應該使用會話或靜態變量來存儲動態生成的(長的故事)連接字符串?