会议是在preRequestHandlerExecute空 [英] Session is null in PreRequestHandlerExecute

查看:137
本文介绍了会议是在preRequestHandlerExecute空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET 4.0应用程序,我有在的global.asax.cs的事件处理程序preRequestHandlerExecute。

In my ASP.NET 4.0 application, I've got an event handler for PreRequestHandlerExecute in global.asax.cs.

我要访问数据库中的会话。大多数时候,会话的定义,但有时为空。有人可以解释我当它被初始化,当它是不是?

I want to access data in the Session. Most times, the session is defined, but sometimes it is null. Can somebody explain me when it is initialized and when it is not?

推荐答案

会话没有加载所有类型的默认请求。如果请求为内容文件(如图像或样式表),则会话未加载。这个工作,以减少处理请求的开销。如果在通用处理器(ashx的)工作,你想访问会话,然后有处理函数中实现ISessionStateRequried。

The session is not loaded for every type of request by default. If the request is for a content file (like an image or stylesheet), then the session is not loaded. This done in order to reduce the overhead of processing a request. If working in the Generic Handler (.ashx) and you want access to the session, then have the handler implement ISessionStateRequried.

这篇关于会议是在preRequestHandlerExecute空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆