Asp.net System.Web.HttpContext.Current.Session 在 global.asax

Asp.net System.Web.HttpContext.Current.Session null in global.asax(Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中为 null)
本文介绍了Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中为 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Query From LDAP for User Groups(从 LDAP 查询用户组)
Active Directory Group Membership Checking in .Net 4.5(.Net 4.5 中的 Active Directory 组成员身份检查)
IIS application using application pool identity loses primary token?(使用应用程序池标识的 IIS 应用程序丢失主令牌?)
ASP .NET MVC Forms authorization with Active Directory groups(ASP .NET MVC 表单授权与 Active Directory 组)
Why when I insert a DateTime null I have quot;0001-01-01quot; in SQL Server?(为什么当我插入 DateTime null 时,我有“0001-01-01?在 SQL Server 中?)
How does appending to a null string work in C#?(追加到空字符串在 C# 中如何工作?)