473,471 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Session object is NULL in HTTP handler

Hi,
I m new with aspnet. I am trying to do an application that writes the
session in a cookie but the context.session is null.

Here in the code, the cookieValue is allways without session, ...
I dont know how to get the session, maybe I cant...

thanks in advance

Miguel

The code is the following:

using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

public class SetIdentity : IHttpModule
{

public void Init(HttpApplication context)
{
context.EndRequest += (new
EventHandler(this.Application_AuthenticateRequest) );
}

protected void Application_BeginRequest(object sender, EventArgs e){
}

private void Application_AuthenticateRequest(object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;

HttpSessionState session = context.Session;
String cookieValue = "without session";
if (session != null) cookieValue = session.SessionID;
// Put it into a cookie
HttpCookie hc = new
HttpCookie("SessionSharePoint", cookieValue);
hc.Expires = DateTime.New.AddMinutes(20);
// Add it to the cookies collection
context.Response.Cookies.Add(hc);
}
public void Dispose()
{
}
}

Nov 19 '05 #1
3 9568
=?Utf-8?B?TWlndWVs?= <Mi****@discussions.microsoft.com> wrote in
news:AB**********************************@microsof t.com:
I m new with aspnet. I am trying to do an application that writes the
session in a cookie but the context.session is null.


Q: I am writing my own HttpHandler. Why is session state not working?
A: Your HttpHandler has to implement the "marker" interface
IRequiresSessionState or IReadOnlySessionState in order to use session
state.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
thanks!
I will see how to do it.
Do I have to add new methods? Well, I'll take a look

thank you

Miguel

"Lucas Tam" wrote:
=?Utf-8?B?TWlndWVs?= <Mi****@discussions.microsoft.com> wrote in
news:AB**********************************@microsof t.com:
I m new with aspnet. I am trying to do an application that writes the
session in a cookie but the context.session is null.


Q: I am writing my own HttpHandler. Why is session state not working?
A: Your HttpHandler has to implement the "marker" interface
IRequiresSessionState or IReadOnlySessionState in order to use session
state.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 19 '05 #3
=?Utf-8?B?TWlndWVs?= <Mi****@discussions.microsoft.com> wrote in
news:1A**********************************@microsof t.com:
thanks!
I will see how to do it.
Do I have to add new methods? Well, I'll take a look

Nope, you just inherit the classes... that's all : )
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: oliver.wulff | last post by:
Hi I wrote a IHttpModule which should store an object in the session. Unfortunately, the session is empty: public void OnAuthenticateRequest(object o, EventArgs ea) { HttpApplication httpApp =...
1
by: Bartosz Krzywicki | last post by:
I have the problem with Session object witch is null, when I implement IHttpHandlerFactory. Implementing IRequiresSessionState interface doesn't help. My code is like this: class MyController :...
7
by: mortb | last post by:
I have written a custom http handler and added it to the web.config file <httpHandlers> <add verb="GET" path="ITImageService.axd" type="ITImageService.ITImageGetter,ITImageService" />...
4
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements...
3
by: Raghu Raman | last post by:
Hi, am in c#.net project. am using the session object for some logic. e-g:session="Add"; i can refer this by using if(Session=="Add") { logic
2
by: Eric Dan | last post by:
Hi, I have written a simple HTTP handler (inherited IHttpHandler) to handle requests for specific extensions. Basically it works. However when trying to access the context.Session object inside...
3
by: ESmith | last post by:
I have multi-page form where I pass an object between pages as follows: On each page: // What page to go to next private void btnContinue_Click(object sender, System.EventArgs e) { if...
3
by: kingski | last post by:
I have a web site created with ASP.NET 1.1. availability Global.asax: protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
7
by: Ty | last post by:
Hi, All- I have a custom httphandler that outputs an image to the browser based upon some user input. I'd like to be able to store information about that image in session and have them...
8
by: eric | last post by:
I have a 2.0 asp.net project. In a class contained within a seperate project, I am trying to reference HttpContext.Current.Session but Session is always null. I've tried implementing...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.