我在 global.asax 中为当前线程设置了一个自定义安全主体对象,一切正常,通常没有问题.
I have a custom security principal object which I set in the global.asax for the current thread and all is well, no problems normally.
但是,我只是通过让页面提供图像来添加动态图像功能,每当加载该动态图像页面时,System.Web.HttpContext.Current.Session 在 global.asax 中为 null,这会阻止我从那时起,将安全主体设置为正常和级联问题.
However, I'm just adding a dynamic image feature by having a page serve up the image and whenever that dynamic image page is loaded the System.Web.HttpContext.Current.Session is null in global.asax which prevents me from setting the security principal as normal and cascading problems from that point onwards.
通常情况下,global.asax 中的 Session 仅在用户登录开始时的会话期间为空一次,之后它始终可用,但有这个例外.
Normally the Session is null in global.asax only once during a session at the start when the user logs in, afterwards it's always available with this single exception.
当浏览器遇到原始页面中的图像标签时加载动态图像页面,即
The dynamic image page is loaded when the browser comes across an image tage in the original page i.e.
我猜这是浏览器请求该页面而不发送一些凭据这一事实的某些方面?
I'm guessing that this is some aspect of the fact that the browser is requesting that page without sending some credentials with it?
任何帮助将不胜感激.
John,
我假设您正在为处理程序使用 ashx 处理程序.如果是这样,请确保从 IRequiresSessionState 派生,例如:
I'm assuming you're using an ashx handler for the handler. If so, be sure to derive from IRequiresSessionState for example:
public class Images : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{ }
如果您不使用 ashx,您能描述一下动态图像页面的含义吗?
If you're not using an ashx can you describe what you mean by dynamic image page?
乔希
这篇关于Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中为 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!