asp.netsessiondirectorydelete-directory

Deleting a directory results in application restart


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).

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.


Solution

  • 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:

    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.