Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

session null on production server

I got an strange exception on my production server:

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] selectie.Functie..ctor() in ..\Page\Specificaties\Functie\Functie.cs:35 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

line 35:

Kast kast = (Kast)HttpContext.Current.Session["kast"];


The session is used in multiple webmethods like:

[WebMethod(EnableSession = true)]
public static String button_click(String information) {

}

and

[WebMethod(EnableSession=true)]
public static void ChangeKast(String id, String value)
{

}

in my search for a solution i found this:

As you might expect, if you enable session support for one Web method, that does not imply that it is enabled for another Web method. In fact, the Context.Session property will be null if EnableSession is not explicitly set to True for a particular Web method.

localy it runs perfectly, and has worked since today... How could i solve this?

like image 449
Sebastiaan Avatar asked Mar 15 '26 21:03

Sebastiaan


1 Answers

Look in Web.Config on the live machine under the <system.web> Element there should an element called <sessionstate> make sure it's not set to Mode="Off"

<configuration>
...
<system.web>
....
<sessionState mode="InProc" cookieless="false" timeout="20" />
....
</system.web>
....
</configuration>
like image 154
kmcc049 Avatar answered Mar 18 '26 09:03

kmcc049



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!