Forum Moderators: open

Message Too Old, No Replies

Directory.Delete = session invalidation?

         

garann

9:24 pm on Aug 1, 2006 (gmt 0)

10+ Year Member



I have a simple page that deletes a directory. When I run it, something weird happens: the session invalidates and I end up back at my login page! The delete works just fine, and there are no errors in my log. I've never seen this behavior before. Does anyone know what's going on?

Thanks!
g.

garann

5:09 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Since it appears that everyone else thinks this is as weird as I do, I thought I'd post back with the solution I found... ASP.NET apparently recycles the AppDomain when a directory is deleted. The way around this is to use out-of-process sessions.

So now I have a second question. Is there any danger to out-of-process sessions? Any reason I shouldn't do it? Right now it's just for an intranet, but some pieces could become public-facing later.

Thanks!

TheNige

7:59 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Where is the folder you are deleting? In the bin folder? I've never seen this behaviour by simply deleting folders that are under the root of your website. If you change someting in the bin folder the application will recycle though.

garann

5:56 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



It's just a folder within the app. Not under /bin. Apparently this is intentional behavior, since the developers of the framework wanted the application to recompile on any major change. I wouldn't think this would extend to every directory in the application, but... there you go. The out-of-process Session fixes it pretty nicely, though, and doesn't kick beta users out of their sessions each time I recompile. :)

TheNige

8:23 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



I'm sorry, but I don't believe this, as I do this all the time in my .Net applications and it doesn't re-compile and lose session state. There must be something in your application that is causing this behavior.

garann

9:31 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Hm. No kidding? The threads I found suggested it was pretty much unavoidable. Though I have to admit, I'd swear I'd never had trouble with deleting directories in past applications, myself.

What version of ASP are you using? And are you doing anything special with your sessions? I'm wondering what on earth would trigger that... Since the threads indicating that an out-of-proc session would fix it were correct, I took them at their word, regarding it being by design.

TheNige

10:58 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



I just created a new test web application with .Net 1.1 framework. Created a web page that set a session variable. Clicked a button that then deletes a directory and redirects to another page where it reads the session variable created on the first page...works fine.

What version of the framework are you using and can you give a sample of the "threads" that tried to explain why the sessions where invalidating?

garann

9:26 pm on Aug 7, 2006 (gmt 0)

10+ Year Member



I'm using ASP.NET 2.0.5... The main thread I found was this one:

[forums.asp.net...]

And then you can see there are several supporting links there. Thoughts?

TheNige

10:38 pm on Aug 7, 2006 (gmt 0)

10+ Year Member



Thanks for the link...yes it appears to have been introduced in .Net 2.0...that is why haven't seen it yet. Looks like lots of people are having the same problems as you which really sucks I think.

Only other way I could think about working around this is to host these folders outside of your web directory. What are your folders that you are deleting used for? Are they temporary?

garann

11:04 pm on Aug 7, 2006 (gmt 0)

10+ Year Member



Unfortunately, I think I read that the problem (or "feature") shows up when you delete even folders outside of the application's directories. In my case, they're documents users upload, which can be linked to or used in various ways within the application, so if they lived outside the application, things would become a little painful since I'd no longer be able to reference them with a simple URL.

But oh well. The out-of-proc session continues to work, so unless I hear that it's dangerous, I guess that's what I'll stick with.