[英]Why my session is getting lost on calling a base
調用基本方法時,我失去了會話,是否有理由獲得空會話?
這是我的控制器動作
public class SystemAdminController : BaseController
{
[HttpPost]
public ActionResult Index(string removeItems)
{
//Session["storedevices"] <<<< my session data is still avail
RemoveItemFromGrid(removeItems); //<<< as soon as I call this method my Session get lost why?
}
}
public class BaseController : Controller
{
public void RemoveItemFromGrid(string items)
{
//Session["storedevices"] //Session is null/lost here?
//to do
}
}
您的代碼發生了一些奇怪的事情。 它應該工作正常。
一些可以幫助您調試的事情:
Session["storedevices"]
在BaseController
的前Controller.Session
實際上是填充屬性。 例如,在Controller的構造函數上應為null。 如果我還記得的話,它只有在Initialize
方法之后才可用。 this.Session == base.Session
。 由於某些原因,您可能正在“更新”后代Controller中的Session
屬性。 只需在此處放置一個斷點並確保該表達式為真即可。 this.Session == System.Web.HttpContext.Current.Session
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.