将图像保存到临时文件夹正在丢失会话

时间:2021-02-22 00:24:17

I have a method that saves an image to a temp folder:

我有一个方法将图像保存到临时文件夹:

System.Web.HttpContext.Current.Server.MapPath("~/bin/temp/")

I debugged each line, and I am sure that the following line is making my application restart, so it is loosing my session:

我调试了每一行,我确信以下行正在使我的应用程序重新启动,因此它会丢失我的会话:

bitmap.Save(pathProcessedImage);

After this method is executed, the Global.asax.cs trigger these events:

执行此方法后,Global.asax.cs会触发这些事件:

Session_End
Application_Start
Session_Start

What can I do?

我能做什么?

1 个解决方案

#1


0  

Storing temporary data in the bin folder doesn't seem to be a good idea. This folder is used to store the binary assemblies used by your ASP application and it is (by default) write protected to avoid hacking. Subfolders created there (if you are able to do it) should take the same restriction of the parent folder. It would be better to store temporary data in the APP_DATA folder that is precisely created for this kind of data.

将临时数据存储在bin文件夹中似乎不是一个好主意。此文件夹用于存储ASP应用程序使用的二进制程序集,并且(默认情况下)写入保护以避免黑客攻击。在那里创建的子文件夹(如果你能够这样做)应该对父文件夹采取相同的限制。最好将临时数据存储在为此类数据精确创建的APP_DATA文件夹中。

However, storing data in a path where you don't have permissions should result in a very visible and clear exception. If you don't see it, then I think that you have used an empty try/catch to hide exceptions. Check your code because hiding exceptions is very wrong

但是,将数据存储在您没有权限的路径中应该会产生非常明显且明确的异常。如果你没有看到它,那么我认为你使用了一个空的try / catch来隐藏异常。检查您的代码,因为隐藏异常是非常错误的

#1


0  

Storing temporary data in the bin folder doesn't seem to be a good idea. This folder is used to store the binary assemblies used by your ASP application and it is (by default) write protected to avoid hacking. Subfolders created there (if you are able to do it) should take the same restriction of the parent folder. It would be better to store temporary data in the APP_DATA folder that is precisely created for this kind of data.

将临时数据存储在bin文件夹中似乎不是一个好主意。此文件夹用于存储ASP应用程序使用的二进制程序集,并且(默认情况下)写入保护以避免黑客攻击。在那里创建的子文件夹(如果你能够这样做)应该对父文件夹采取相同的限制。最好将临时数据存储在为此类数据精确创建的APP_DATA文件夹中。

However, storing data in a path where you don't have permissions should result in a very visible and clear exception. If you don't see it, then I think that you have used an empty try/catch to hide exceptions. Check your code because hiding exceptions is very wrong

但是,将数据存储在您没有权限的路径中应该会产生非常明显且明确的异常。如果你没有看到它,那么我认为你使用了一个空的try / catch来隐藏异常。检查您的代码,因为隐藏异常是非常错误的