【问题标题】:Losing session in asp.net在 asp.net 中丢失会话
【发布时间】:2017-09-20 21:56:48
【问题描述】:

你好,对不起我的英语不好,

我有一个 Asp.Net 应用程序在我添加 Log.Net 框架(登录单个文件)并在线程中添加图片生成之前运行良好。

我会随机丢失所有会话变量。

我尝试不使用 Log4Net 登录(在配置文件中)。

我在 global.asax 中添加了登录 session_end 以了解为什么应用程序池回收被午餐,我得到了这个堆栈跟踪:

shutDownMessage=CONFIG change
HostingEnvironment initiated shutdown
HostingEnvironment a provoqué un arrêt.

_shutDownStack=   à System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   à System.Environment.get_StackTrace()
   à System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
   à System.Web.Hosting.HostingEnvironment.InitiateShutdownWithoutDemand()
   à System.Web.HttpRuntime.ShutdownAppDomain(String stackTrace)
   à System.Web.Configuration.HttpConfigurationSystem.OnConfigurationChanged(Object sender, InternalConfigEventArgs e)
   à System.Configuration.Internal.InternalConfigRoot.OnConfigChanged(InternalConfigEventArgs e)
   à System.Configuration.BaseConfigurationRecord.OnStreamChanged(String streamname)
   à System.Web.Configuration.WebConfigurationHostFileChange.OnFileChanged(Object sender, FileChangeEvent e)
   à System.Web.DirectoryMonitor.FireNotifications()
   à System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
   à System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
   à System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   à System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   à System.Threading.ThreadPoolWorkQueue.Dispatch()
   à System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

ShutDownMessage 是“配置更改”,但我没有对配置文件进行任何更改,即使在 bin 文件夹中也是如此。

我唯一做的就是在网站的特定文件夹中删除和创建图片。

即使我没有对 bin 文件夹进行任何更改,Asp.Net 文件更改通知也会导致启动 App Recycling 吗?

提前感谢您的帮助。

【问题讨论】:

    标签: asp.net multithreading recycle


    【解决方案1】:

    global.asax 中的这段代码也可以工作:

      Dim theRuntime = GetType(HttpRuntime).GetField("_theRuntime", BindingFlags.NonPublic Or BindingFlags.[Static]).GetValue(Nothing)
        Dim fcmField = GetType(HttpRuntime).GetField("_fcm", BindingFlags.NonPublic Or BindingFlags.Instance)
        Dim fcm = fcmField.GetValue(theRuntime)
    
        fcmField.FieldType.GetMethod("Stop", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(fcm, Nothing)
    

    【讨论】:

      【解决方案2】:

      如果它可以帮助某人:

      添加 FCNMode 注册密钥对我有帮助

      https://weblogs.asp.net/owscott/ASP.NET-v2.0-2D00-AppDomain-recycles_2C00_-more-common-than-before

      “此外,如果许多文件是连续添加的,这也将导致相同的重新启动”--> 网站文件夹中线程中的图片生成导致 AppDomain 为我回收(使用 windows server 2012 R2)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-18
        • 2021-03-03
        • 1970-01-01
        相关资源
        最近更新 更多