在wwroot文件夹ASP.Net MVC3中创建临时文件 [英] Creating temporary files in wwroot folder ASP.Net MVC3

查看:103
本文介绍了在wwroot文件夹ASP.Net MVC3中创建临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个应用程序,其中在一个临时文件夹中生成了一些pdf报告.临时文件夹位于wwroot文件夹内.现在,有时会在生成pdf后立即破坏会话.

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.

这是由于临时文件生成引起的吗?临时文件夹是否应该位于wwroot文件夹之外?

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.

您的会话被破坏的原因是因为IIS在修改15个文件后会重新启动应用程序.一个简单的解决方法是在IIS中创建一个虚拟目录,指向根目录之外的文件夹,然后将文件写入该目录.

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.

这样,您的网站不需要任何对文件夹的硬引用,但可以使用MapPath将虚拟目录映射到物理文件夹

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

这篇关于在wwroot文件夹ASP.Net MVC3中创建临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆