删除目录导致应用程序重新启动 [英] Deleting a directory results in application restart

查看:132
本文介绍了删除目录导致应用程序重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含2个目录(书籍和出口)的应用程序。
如果我们在应用程序中创建一本书或一本书的页面,那么添加一个目录,该页面的ID为该页面的id(用于上传资源)。
如果我们删除一个页面,页面(和它的目录)将从数据库和文件系统中删除。



但是这导致会话丢失(甚至应用程序重启)。我已经在google上查找了一些内容,并找到以下链接
这似乎是ASP.NET 2.0(和3.5)中的一个问题。
有没有人有这个问题的解决方案。



我们正在考虑在晚上编写一个清理目录的服务。
但是这个不一定有另一个解决方案吗?
哦,把目录放在虚拟目录之外是不是一个选项。

解决方案


哦,把目录放在
之外,虚拟目录不是一个
选项。


将目录放在虚拟目录是我发现的唯一解决方案(到目前为止)。您可以做的是在文件系统中创建一个链接(连接),以便该目录似乎位于虚拟目录中,例如:




  • 我们的网站(虚拟目录)位于C:\projectX\website

  • 数据目录(我们创建/删除文件和文件夹)位于C: \projectX\data

  • 然后我们创建一个链接,使数据文件夹可用C:\projectX\website\data



    • 链接是使用程序Linkd.exe(Windows资源工具包中提供的)创建的,并使用以下命令:

        linkd c:\projectX\website\data c:\projectX\data 

      现在c:\projectX\website\data是指向真实数据目录的链接/结点。您可以像链接一样使用物理目录。



      例如。在您的网站中,您可以使用以下代码访问它:

        Server.MapPath(〜/ data)
      您还可以使用Windows文件浏览器并浏览到C:\projectX\website\data。

      它看起来就像一个真实的目录。


      I have an application with 2 directories (books and export). If we create a book or a page of a book in the application a directory is added with the id of the page (this is for uploading resources). If we delete a page, the page (and it's directory) is removed from the database and the filesystem.

      However this resulted in a session loss (even an application restart). I've looked up some thing on google and found the following link. It seems to be a problem in ASP.NET 2.0 (and 3.5). Does anyone have a solution for this problem.

      We are now thinking about writing a service that will clean up the directories at night. But there has got to be another solution for this no? Oh and putting the directory outside the virtual directory is not an option.

      解决方案

      Oh and putting the directory outside the virtual directory is not an option.

      Putting the directory outside the virtual directory is the only solution I found (so far). What you can do, is to create a link (junction) in the file system so that the directory appears to be inside the virtual directory, e.g:

      • Our web site (virtual directory) is located at C:\projectX\website
      • the data directory (where we create/delete files and folders) is located at C:\projectX\data
      • then we create a link which makes the data folder available as C:\projectX\website\data

      The link is created using the program Linkd.exe (available in the windows resource kit), with the following command:

      linkd c:\projectX\website\data c:\projectX\data
      

      Now c:\projectX\website\data is a link/junction which points to the real data directory. You can work with the link as if it were a physical directory.

      E.g. in your web site you can access it using this code:

      Server.MapPath("~/data")
      

      And you can also used the windows file explorer and browse to C:\projectX\website\data. It appears just like a real directory.

      这篇关于删除目录导致应用程序重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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