我試圖訪問會話變量的自定義類裏,像這樣:HttpContext的會議總是空
控制器:
public void RemoveMachinesListChanged(object sender, RemovePackageEvent e)
{
PackageActionStatus.Current.Machines = e.Machines;
// Dictionary<int, int> machines = e.Machines;
}
public class PackageActionStatus
{
public static PackageActionStatus Current
{
get
{
HttpContextWrapper context = new HttpContextWrapper(System.Web.HttpContext.Current);
var session = (PackageActionStatus)context.Session["PackageActionStatus"];
if (session == null)
{
session = new PackageActionStatus();
context.Session["PackageActionStatus"] = session;
}
return session;
}
}
private Dictionary<int, int> machines;
public Dictionary<int, int> Machines
{
get
{
return this.machines;
}
set
{
if (this.machines == null)
{
this.machines = new Dictionary<int, int>();
}
this.machines = value;
}
}
}
什麼我」 m試圖在這裏實現通過AJAX調用來存儲和從/向會話變量檢索值。看來,只要我使用ajax HttpContext爲null。我會怎麼做? 謝謝
怎麼叫這門課嗎? – jgauffin