簡體   English   中英

為什么我的會議在打電話給基地時迷路了

[英]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屬性。 只需在此處放置一個斷點並確保該表達式為真即可。
  • 確保后代Controller和基礎Controller中的this.Session == System.Web.HttpContext.Current.Session

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM