2013-09-23 2 views
0

HttpContext를 사용하여 세션 변수를 가져오고 설정하려는 메서드에 대한 비동기 호출을 만들고 있습니다. 하지만 HttpContext는 usign을 사용하는 동안 null을 표시합니다. 어떻게 HttpContext를 사용할 수 있습니까?비동기 호출에 HttpContext를 사용하는 방법

코드 :

public void SessionsFetchAllWatchNowAsync() 
     { 
      string aaa = Convert.ToString(HttpContext.Current.Session["UserID"]); 


     } 
     protected void Page_Load(object sender, EventArgs e) 
     { 

      Session[Utility.UserID] = 0; 
      Action<StartPage> notifyTask = null; 
      notifyTask = new Action<StartPage>((o) => new StartPage().SessionsFetchAllWatchNowAsync()); 
      if (notifyTask != null) 
       notifyTask.BeginInvoke(null, null, null); 
     } 

감사합니다,

Dalvir

답변

1

HttpContext.Current는 당신이 그것을 사용하기 위해 귀하의 비동기 메소드에 전달해야합니다 의미하는 스레드에서 설정 비동기 메서드를 처리하는 스레드는 ASP.NET이 요청을 처리하기 위해 만든 스레드가 아니기 때문입니다.

관련 문제