如何防止 ashx 重置会话超时?

发布于 2024-08-03 04:53:11 字数 755 浏览 3 评论 0原文

我无法找到任何相关信息,这让我觉得我做错了什么。我制作了一个 ashx,为我们的登录用户提供安全图像。问题在于,Sql Profiler 跟踪显示,在会话状态数据库中为通过此机制提供的每个图像调用了 TempResetTimeout。这个 ashx 的构建是为了替换一个 aspx,它曾经做同样的事情,但由于许多图像和网络花园的使用而导致许多会话状态数据库死锁,yada,yada。这绝对是一项改进,因为减少了对会话状态数据库的“已提交读取”调用,但事实上有更新意味着我们仍然可能会遇到一些死锁。基本上,我们不希望使用这个 ashx 来进行任何会话交互,但这似乎并没有发生。

我当然没有实现 IRequiresSessionState 接口,所以我相信我的 ashx 不应该以任何方式接触 Session。然而,我看到 Global.asax 每次出现都会命中,并且 Global.asax 在其某些代码中引用了会话。这导致我尝试通过 web.config 中的以下内容从任何类型的身份验证中排除此特定页面...

<location path="ImageHandler.ashx">
<system.web>
    <authentication mode="None" />
</system.web>
</location>

...但这会导致 ashx 根本不触发(没有显示图像,并且 ProcessRequest 中没有断点命中)。我不知道为什么会发生这种情况。

如何让 ashx ImageHandler 完全不接触会话?

I'm having trouble finding any info on this, which makes me think I'm doing something wrong. I've made an ashx that serves up secured images to our logged-in users. The problem is that a Sql Profiler trace reveals that TempResetTimeout is called in our Session State DB for every image served via this mechanism. This ashx was built to replace an aspx that used to do the same thing but was causing many session state db deadlocks due to many images and web garden usage, yada, yada. This is definitely an improvement, due to one less "Read Committed" call to session state db, but the fact that there's an update means we can still have some deadlocks. Basically, we want NO session interaction at all from the use of this ashx, but that doesn't seem to be happening.

I certainly don't have the IRequiresSessionState interface implemented, so I am led to believe that my ashx should not touch Session in any way. I see Global.asax hit for every occurrence however, and Global.asax references session in some of its code. This led me to try to exclude this particular page from any sort of authentication via the following in web.config...

<location path="ImageHandler.ashx">
<system.web>
    <authentication mode="None" />
</system.web>
</location>

...but this causes the ashx to not fire at all (no image displayed and no breakpoint hit in ProcessRequest). I'm not sure why that is happening.

How can I get my ashx ImageHandler to not touch session AT ALL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-08-10 04:53:11

SessionState 是在应用程序级别设置的,因此禁用任何 ASP.NET 请求的会话的唯一方法是将其放入 IIS 中其自己的应用程序中并转换会话状态离开。

<system.web>
    <sessionState mode="Off" />
</system.web>

http://msdn.microsoft.com/en-us/library/h6bb9cz9。 aspx

您还可以创建自己的会话状态模块(也许尝试包装现有的会话状态模块),但这也需要 IIS 配置将另一个文件夹设置为应用程序,或者在根应用程序上替换它。

http://msdn.microsoft.com/en- us/library/system.web.sessionstate.sessionstatemodule.aspx

尽管这看起来比仅仅为 IIS 中配置为应用程序的一个子文件夹关闭它要花费更多的精力。

SessionState is set up on an Application level, so the only way to disable session for any ASP.NET request is to put it in its own Application in IIS and turn session state off.

<system.web>
    <sessionState mode="Off" />
</system.web>

http://msdn.microsoft.com/en-us/library/h6bb9cz9.aspx

You could also create your own session state module (perhaps trying to wrap the existing one), but that also would either require IIS configuration to set up another folder as an Application, or replacing it on your root application.

http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstatemodule.aspx

Though that just seems like a lot more effort than just turning it off for one subfolder that's configured as an Application in IIS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文