删除文件夹时丢失会话为什么? [英] Lose of session when delete a folder Why ?

查看:63
本文介绍了删除文件夹时丢失会话为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除用户的某些文件和文件夹。删除成功,但我的会话丢失。

我正在使用此代码。



i need Delete Some File And Folder of a user . it's Delete Successful but my session is loss .
am using this code .

try
{
   
    foreach (string file in Directory.GetFiles(strpath))
    {
        File.Delete(file);
    }

    Directory.Delete(strpath);
}
catch { }

推荐答案

问题



这是因为您正在删除子目录或您所谓的Web应用程序的文件夹。

实际上导致应用程序域回收。因此,由于 InProc 会话状态模式,会话将丢失。

解决方案



如果要保留此方案的会话,则应使用 StateServer 模式或而不是 SQLServer 模式。

更多信息



会话状态模式 [ ^ ]。

Problem


It is because you are deleting sub directory or what you call a "folder" of your web application.
That actually causes application domain recycle. So, the session is lost due to the "InProc" session state mode.

Solution


If you want to preserve session for this scenario, you should use "StateServer" mode or "SQLServer" mode instead.

More Info


Session-State Modes[^].


这篇关于删除文件夹时丢失会话为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆