Create a session CurrentContext.Session["test"] = "Hello"; when inspect Session should be init, as make sure that on Global.asax.cs Session_Start was called
But the session is null. All I get is: Object reference not set to an instance of an object. Line 389: FBrowserContext.Session[Item] = value; Do I manually create a session?
For session state to be available to a handler, the handler has to implement IReadOnlySessionState (for read-only access) or IRequiresSessionState (for read-write access). For example:
<div style="BORDER-RIGHT: black 1pt solid; BORDER-TOP: black 1pt solid; FONT-SIZE: 8pt; BORDER-LEFT: black 1pt solid; BORDER-BOTTOM: black 1pt solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #d3d3bd">publicclassMyHandler :
IHttpHandler,
IRequiresSessionState { // ... } </div>
There are no actual methods to implement for IRequiresSessionState - it is just a "marker" interface that ASP.NET will look for at runtime. If it find the interface it goes to the trouble of making session state available.
Hope that helps,
Scott
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
Marked as answer by KillerApp on Jan 02, 2007 09:08 PM
Debugging by post is a hard thing to do, if he post the details I can see what he may be missing. If session is null and creating a session fixes that = means he is using cassini and the httpmodule loads before the Session_Start gets called.
The poster asked about the ProcessRequest method of an HttpHandler. By the time ASP.NET executes ProcessRequest, the session state module is done its work. The most common cause of having a null Session object in an HttpHandler is forgetting to tag the handler
with IRequiresSessionState or IReadOnlySessionState.
Scott
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
KillerApp
Member
6 Points
11 Posts
context.Session is null in ProcessRequest
Jan 01, 2007 10:57 PM|LINK
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 01, 2007 11:55 PM|LINK
Al
My Blog
KillerApp
Member
6 Points
11 Posts
Re: context.Session is null in ProcessRequest
Jan 02, 2007 08:24 AM|LINK
bitmask
Contributor
6739 Points
1245 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 02, 2007 02:50 PM|LINK
For session state to be available to a handler, the handler has to implement IReadOnlySessionState (for read-only access) or IRequiresSessionState (for read-write access). For example:
<div style="BORDER-RIGHT: black 1pt solid; BORDER-TOP: black 1pt solid; FONT-SIZE: 8pt; BORDER-LEFT: black 1pt solid; BORDER-BOTTOM: black 1pt solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #d3d3bd">public class MyHandler : IHttpHandler, IRequiresSessionState{
// ...
} </div>
There are no actual methods to implement for IRequiresSessionState - it is just a "marker" interface that ASP.NET will look for at runtime. If it find the interface it goes to the trouble of making session state available.
Hope that helps,
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 02, 2007 03:50 PM|LINK
Al
My Blog
bitmask
Contributor
6739 Points
1245 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 02, 2007 04:13 PM|LINK
Albert: you should research the problem a bit more.
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
albertpascua...
All-Star
17520 Points
3475 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 02, 2007 04:19 PM|LINK
Al
My Blog
bitmask
Contributor
6739 Points
1245 Posts
MVP
Re: context.Session is null in ProcessRequest
Jan 02, 2007 05:03 PM|LINK
The poster asked about the ProcessRequest method of an HttpHandler. By the time ASP.NET executes ProcessRequest, the session state module is done its work. The most common cause of having a null Session object in an HttpHandler is forgetting to tag the handler with IRequiresSessionState or IReadOnlySessionState.
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
KillerApp
Member
6 Points
11 Posts
Re: context.Session is null in ProcessRequest
Jan 02, 2007 09:06 PM|LINK
miztiik
Member
182 Points
236 Posts
Re: context.Session is null in ProcessRequest
Jan 13, 2007 01:51 AM|LINK
is it advicable to have the data handler depending on the web session ?
can you have a look at this post..
http://forums.asp.net/thread/1524372.aspx