Creating temporary files in wwroot folder ASP.Net

2019-08-28 20:27发布

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 ?

3条回答
趁早两清
2楼-- · 2019-08-28 20:50

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

查看更多
家丑人穷心不美
3楼-- · 2019-08-28 21:09

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

查看更多
聊天终结者
4楼-- · 2019-08-28 21:12

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

查看更多
登录 后发表回答