views:

684

answers:

5

Hi,

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: http://www.vikramlakhotia.com/Deleting_Directory_in_ASPnet_20.aspx. 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.

Kind Regards, Sem

A: 

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

+4  A: 

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.

M4N
I know of this approach. You can even doe this in IIS without Linkd.exe. But we don't have the possibility to do this for now. It's not a dedicated server.
Sem Dendoncker
Ok, sorry for the misunderstanding.
M4N
This is not a problem. Thx for trying to help out.
Sem Dendoncker
@sam > This is the best option available right?
naveen
@naveen: yes it is. eventually we've done it this way!!
Sem Dendoncker
+2  A: 

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

Sachin Gaur
there is a space to many ;) in the link
Sem Dendoncker
I will definatly try this approuch. Thx all for helping me out
Sem Dendoncker
I fixed the link. Although I wonder whether this is a reliable solution, since it seems to set some internal properties via reflection?
M4N
This actually works, but i wonder if you can turn this back on after deletion? Because, if we upload a dll in the bin folder we expect the application to restart. and I don't know if this is still possible then.
Sem Dendoncker
A: 

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.

M4N
+1  A: 

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

Aleksandar