非同期Webサービス呼び出しを必要とするAsp.Net3.5Webアプリケーションに取り組んでいます。ここにいくつかのコードがあります。デリゲートを使用して非同期呼び出しのコードを記述しましたが、どういうわけかHttpContext.Current.Sessionがnullです。念のため、HttpContextを渡してみました。
static HttpContext httpContext;
public void AsyncGetUser()
{
httpContext = HttpContext.Current;//not getting Session as null here
GetUserDelegate delegate = new GetUserDelegate(InvokeWrapperMethod);
IAsyncResult async = delegate.BeginInvoke(httpContext,new AsyncCallback(CallbackMethod), null);
}
static void CallbackMethod(IAsyncResult ar)
{
AsyncResult result = (AsyncResult)ar;
GetUserDelegate caller = (GetUserDelegate)result.AsyncDelegate;
caller.EndInvoke(ar);
}
private static void InvokeWrapperMethod(HttpContext hc)
{
HttpContext.Current = hc; //getting Session as null here
UserInfo userInfo = Service.GetUserInfo();
SetInSession(USER_INFO, userInfo);
}
私は試しまし<modules runAllManagedModulesForAllRequests="true">
た
<system.webServer>
<modules>
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</modules>
このSOの質問が示唆したように、機能しませんでした。皆さんがいくつかの指針を与えることができれば幸いです。ありがとう。