Madam Zu Zu
Madam Zu Zu

Reputation: 6605

Trying to get session from a static method, but getting NULL

i am trying to get the current user session from a static function, but the usObj is always null.

here is what i'm doing:

public static List<RequestTypeBL> GetRequestType(string itemNo, int requestTypeID, int claimID) {
    UserSession usObj = (UserSession)HttpContext.Current.Session["UserSessionObj"];
    RequestTypeBL reqTypeBL;
    reqTypeBL= SERT_BO.RequestTypeBL.GetClaimRequestType(claimID, requestType, usObj.UserID, itemNo);

am i missing something? please help.

i am able to do the following from regular functions just fine:

return (UserSession)Session["UserSessionObj"];

i am seeing this behavior in our production environment only, when the same code is run in development,everything works as it should. could it have something to do with an IIS setting of some sorts?

Upvotes: 0

Views: 1748

Answers (1)

Johann P&#233;rez
Johann P&#233;rez

Reputation: 367

Something similar happened to me once and it was because of the amount of worker threads that the application pool was using, the development webserver used only one. The request were not always answered by the same thread. I don't remember where to configure that on IIS, not sure you are using IIS either. Hope it helps.

Upvotes: 1

Related Questions