1

I have a web app where the administrator can create news, pdf documents and other stuff in his cms panel.

The problem is when the admin delete a new or something else the app deletes all the files related to that new, I mean the images, pdfs and other documents. Tha main problem is those files are stored in folders under the "news" folder and when the app deletes them the session is lost.

How can I do to have a file system without losing the session? I'd like that file system within the app folder...

Impossible for us to store those folders outside the app and we don't want to use StateServer because of the performanne....

Any other solution?

Thanks

John Mathison
  • 904
  • 1
  • 11
  • 36

3 Answers3

1

Your session is lost becasue IIS recompiles. The easiest solution in my opinion is to store your files outside the wwwroot.

Discussed on SO: ASP.NET restarts when a folder is created, renamed or deleted

[Update] Example: Let's stay your app is in c:\inetpub\wwwoot\virtualdir1

You make a work directory: c:\inetpub\inetwork

Give the proper rights (read/write/etc) to the Asp.net user of your app pool and it should all work like a charm. More info on setting the rights: What are all the user accounts for IIS/ASP.NET and how do they differ?

Store the path to the workdirectory in your web.config (you no not want to hardcode it)

Community
  • 1
  • 1
Pleun
  • 8,856
  • 2
  • 30
  • 50
  • Can you give me an example? Also, when losing Session you also lose Forms Authentication, right? – John Mathison Sep 01 '11 at 10:41
  • Thanks, but that solution won't work since on Plesk control panel you cannot setup any content outside of Plesk or Plesk will reset any permission changes you have made when running maintenance...so anything outside the domain folder... – John Mathison Sep 01 '11 at 13:52
0

Having those files within the app folder is a poor desgin. The session is probably lost as you are causing IIS to recycle due to the file system changes. It is much safer to not have your web application able to write to its own folder, doing so is a security risk.

kmcc049
  • 2,783
  • 17
  • 13
  • So, you mean store the users files of each web site outside the "inetput" or "vhost" folder? Something like "C:/User_Data" in the server? But, how can I access to all the info? I can't use a "~/" route... – Mike Johnson 0 secs ago edit – John Mathison Sep 01 '11 at 10:40
  • To access them via the web create a virtual directory in iis that points at the folder. – kmcc049 Sep 01 '11 at 10:43
  • So, I have those files in a folder, for example, "C:\Files\". I have to create a Virtual Directory that points to that folder and then access to that Virtual Directory from the web app, right? DO you have an example? – John Mathison Sep 01 '11 at 10:55
  • The virtual directory is setup in iis as directory, so it appears as simply a folder in your site. Its simply a matter of configuring that in iis so theres not much I can show you. To access from server side code you will need to either have the path in a config file or you could try server.mappath (although I've never tried this with a virtual dir so dont know if it will work) – kmcc049 Sep 01 '11 at 11:00
0

Separate your document folder and web site folder. And give right permission your document folder.

Ethem Kuloglu
  • 703
  • 1
  • 5
  • 9