使用 SQL Server 会话时 ASP.Net 图表工具图像消失
我们正在使用 ASP.Net 图表工具(版本 3.5),并希望将图表图像存储在 SQL Server 会话中。这是 web.config 中的部分:
<add key="ChartImageHandler" value="storage=session;timeout=20;" />
我们在 web.config 中的会话设置如下所示:
<sessionState mode="SQLServer" sqlConnectionString="Data Source={sql server name}; Integrated Security=SSPI;" cookieless="false" timeout="30"/>
第一次加载页面时,图表图像工作正常。但此后每次都无法加载。我们得到红色 X/未找到图像的图形。看起来好像图像没有正确保存到会话中,但更改“超时”值并没有帮助。
文件存储选项版本确实有效:
<add key="ChartImageHandler" value="Storage=file;Timeout=800;Dir=C:\Directory\TempChartFiles;"/>
但是,我们更愿意使用 SQL Server 会话选项。有没有办法让 SQL Server 会话选项与 ASP.Net 图表工具一起使用?
We're using the ASP.Net charting tools (version 3.5) and would like to store the chart images in SQL Server session. Here's the section in the web.config:
<add key="ChartImageHandler" value="storage=session;timeout=20;" />
And our session setting in the web.config looks like this:
<sessionState mode="SQLServer" sqlConnectionString="Data Source={sql server name}; Integrated Security=SSPI;" cookieless="false" timeout="30"/>
The chart image works fine the first time a page is loaded. However, it fails to load every time after that. We get the red X/image not found graphic. It appears as if the image isn't saved properly to the session, but changing the "timeout" value doesn't help.
The file storage option version does work:
<add key="ChartImageHandler" value="Storage=file;Timeout=800;Dir=C:\Directory\TempChartFiles;"/>
We'd, however, prefer to use the SQL Server session option instead. Is there any way to get the SQL Server session option to work with the ASP.Net charting tools?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我不确定您在哪里设置密钥。它是否在或者您是否已将其设置在更具体的地方。接下来,如何将代码设置为 Render。
据我所知,您期望一些神奇的 ASP.NET 精灵来存储该值并自动从会话中为您提取它,这不是会话的工作方式。
另外,我不确定业务问题是什么,所以我什至不确定session是否是最好的存储位置。 ASP.NET 有一组出色的缓存选项,这些选项可以更特定于用户,也可以更特定于应用程序,具体取决于您的需要。它也不是自动的,但通常比使用 Session 来存储东西效果更好。
在我看来,这里的问题是您缺少一些实际处理会话存储的代码,而不是 SQL Server 问题。我要指出的是,在这种情况下,SQL Server 可能是一个糟糕的会话选项,特别是当您最终得到更大的图形时。与其他缓存解决方案相比,您可以大大降低可扩展性。换句话说,我不相信会话在任何情况下都是一个好的选择,但对于 SQL Server 来说可能更糟。
使用 SQL Server 进行会话状态的主要原因是以下之一:
如果您有更多代码并可以跟进更具体的业务原因,您可能会获得有关如何解决问题的更全面的答案。
First, I am not sure where you are setting up your key. Is it in or have you set it up somewhere more specific. Next, how is teh code set up to Render.
From what I see, you are expecting some magic ASP.NET fairy to store the value and automagically pull it from session for you, which is not how session works.
In addition, I am not sure what the business problem is, so i am not even sure if session is the best place to store. ASP.NET has a wonderful set of caching options that can be more user specific or more application specific, depending on your needs. It is also not automagic, but often works better than using Session to store things.
The issue here, as I see it, is you are missing some code to actually handle the session storing, and not a SQL Server issue. I will state that SQL Server may be a bad Session option in this case, especially if you end up with larger graphics. You can greatly reduce your scalability over other caching solutions. In other words, I am not convinced session is a good option in any case, but possibly worse with SQL Server.
The main reason to use SQL Server for session state is one of the following:
If you have more code and can follow up with a more specific business reason, you will likely get more thorough answers on how to solve the problem.