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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try disabling the monitoring of File System. This will prevent your session alive.
This article may be usefull for you.

Method 2

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:projectXwebsite
  • the data directory (where we create/delete files and folders) is located at C:projectXdata
  • then we create a link which makes the data folder available as C:projectXwebsitedata

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

linkd c:projectXwebsitedata c:projectXdata

Now c:projectXwebsitedata 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:projectXwebsitedata. It appears just like a real directory.

Method 3

There seems to be a supported hotfix which achieves the same as the article Sachin mentioned (turn off the file change notifications in a web site).

Check this article in the microsoft KB for more information.

But since you mentioned in a comment, that you do not have access to the server, I guess this will also not help in your case.

Method 4

For storing data files that are frequently updated, created and deleted you need to use App_Data folder in the root of the web site. MSDN for App_Data folder states:

Contains application data files
including MDF files, XML files, as
well as other data store files. The
App_Data folder is used by ASP.NET 2.0
to store an application’s local
database, which can be used for
maintaining membership and role
information.

Also check Q&A section for App_Data folder usage: App_Data folder question

Method 5

I had the same problem. The solution is to externalize the session handling by using the ASP.Net State service. The only draw back is that every object you place in the session needs to be serializable, as it is transferred to the state service and back.

I currently do not have the possibility to provide further links, but google will help you, now that you know what to search for.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x