Question

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.

Was it helpful?

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:

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

OTHER TIPS

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

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.

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top