Creating a folder clears ASP.NET session - advice?

Associate
Joined
24 Jul 2003
Posts
1,420
Location
West Mids
I've got a really annoying problem where every time I create a new folder inside my site, or even using .NET itself, any active sessions with my web app keep getting reset.

Anyone got any ideas why this is and how I can stop it?
 
Because your website folder structure is changing at runtime .NET recompiles so the session is getting reset. To stop this in your web.config add

<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" stateNetworkTimeout="10"/>

Also, at the command line type in services.msc to start the state service.
 
Thanks for that :)

It's working on my local dev machine, but not the shared hosting we've got. I contacted them just now but they said it's not enabled...back to the drawing board.
 
Found a solution - pre-compiled the website with "Allow this precompiled site to be updatable" unchecked :)

Added a folder and it didn't reset.
 
Found a solution - pre-compiled the website with "Allow this precompiled site to be updatable" unchecked :)

Added a folder and it didn't reset.
Although you'd still probably be better off creating these folders in a separate virtual directory. It's not a particularly good idea to allow the production asp.net account write permissions on the application root. What are you creating the folders for?
 
It's not a particularly good idea to allow the production asp.net account write permissions on the application root. What are you creating the folders for?

Basically, think of a web page that looks like Windows Explorer (albeit simplified functionality) with a file upload and the ability to create folders :) It's part of a larger project I've been working on to come up with some kind of bespoke CMS/e-Learning solution for work.

I've defined a folder within the site that has write permissions and then files and folders can be created only within this specified folder.
 
Last edited:
Back
Top Bottom