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 ?
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
Why not use the App_Data
folder? It's much more simple and you will not have this kind of problem.
I finally added a folder outside the wwwroot folder, linked it via virtual directory which solved the problem.