我无权访问的模块中的 HttpContext.Current.Session 为 null

发布于 2024-08-08 01:58:14 字数 438 浏览 3 评论 0 原文

我正在尝试按照此处某人的推荐使用此上传控件:

http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/

所以我试图实现一个自定义处理器,以便将上传的文件存储在会话中。但是,当文件(从 HttpModule)传递到处理器时,SEssion 为空。

谷歌搜索显示我应该向模块添加“IREquiresSessionState”或其他内容,但是我无权访问该模块,因为它位于 dll 中 - 所以我需要一个替代方案。有人能想到一个吗?

谢谢

I am trying to use this upload control as recommended by someone on here:

http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/

So I'm trying to implement a custom processor in order to store the uploaded files in the session. However, when the file is passed to the processor (from the HttpModule) the SEssion is null.

Googling shows that I should add "IREquiresSessionState" or something to the Module, however I don't have access to the module as it is in a dll - so I need an alternative. Can anyoen think of one?

Thanks

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

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

发布评论

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

评论(1

花伊自在美 2024-08-15 01:58:14

我发现了 Global.asax 的这个方法:

protected void Application_PostRequestHandlerExecute(Object sender, EventArgs e)

它仍然知道 SessionState,但是在请求完成之后。因此,HttpModule 之后的处理可以在那里发生(项目仅存储在 Context.Items 中,而不是直接存储到会话中)。

有点脏?是的,但是解决了问题

I have discovered this method of the Global.asax:

protected void Application_PostRequestHandlerExecute(Object sender, EventArgs e)

This still knows about SessionState, but after the request has finished. So the processing after the HttpModule can happen in there (the items are just stored in Context.Items instead of straight into the session).

Slighty dirty? Yes, but solves the problem

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