gpt4 book ai didi

c# - 生产服务器上的 session 为空

转载 作者:行者123 更新时间:2023-11-30 15:42:52 25 4
gpt4 key购买 nike

我的生产服务器出现了一个奇怪的异常:

来源错误:

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.

堆栈跟踪:

[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

第 35 行:

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


该 session 用于多个网络方法,例如:

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

}

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

}

在寻找解决方案时,我发现了这个:

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.

它在本地运行完美,从今天开始就一直在工作...我该如何解决这个问题?

最佳答案

<system.web> 下的live 机器上的Web.Config 中查看元素 那里应该有一个名为 <sessionstate> 的元素确保它没有设置为 Mode="Off"

<configuration>
...
<system.web>
....
<sessionState mode="InProc" cookieless="false" timeout="20" />
....
</system.web>
....
</configuration>

关于c# - 生产服务器上的 session 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7189558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com