0

I have developed an application in which some pdf reports are generated in a temporary folder. The temp folder is located inside the wwroot folder. Now, sometimes the session gets destroyed as soon as a pdf is generated.

Is this caused due to temp file generation ? Should the temp folder be outside wwroot folder ?

Nitin Kabra
  • 3,146
  • 10
  • 43
  • 62

3 Answers3

1

Yes, you should place that folder outside the root folder.

The reason your session gets destroyed is because IIS restarts the application when 15 files are modified. An easy workaround is to create a virtual directory in IIS, pointing to a folder outside the root and then write the files to that directory.

That way, your website doesn't need any hard references to a folder but can use MapPath to map the virtual directory to a physical folder

Kenneth
  • 28,294
  • 6
  • 61
  • 84
  • I didn't know that saving 15 files(PDF) inside a folder inside wwwroot cause IIS reset. any online acceptable proof you are aware of? – chamara Aug 09 '13 at 14:20
  • @chamara : IIS does restart after any new files are added to the wwroot folder, but i am not sure about when it does. – Nitin Kabra Aug 09 '13 at 18:24
0

Why not use the App_Data folder? It's much more simple and you will not have this kind of problem.

Davidson Sousa
  • 1,353
  • 1
  • 14
  • 34
  • We are clearly talking about 2 different things: 1 - If you add files into the project (javascript files, views, etc) your session is likely to be reseted since the application will be restarted. 2 - The App_Data folder is the best place so far to store any kind of files your website will need, including temporary pdf files. So, if you want to generate temporary PDF files in your application I strongly recommend to store them into the App_Data folder and then delete after some time. – Davidson Sousa Aug 09 '13 at 20:57
0

I finally added a folder outside the wwwroot folder, linked it via virtual directory which solved the problem.

Nitin Kabra
  • 3,146
  • 10
  • 43
  • 62