Session object is NULL in HTTP handler
- From: Miguel <Miguel@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 06:38:02 -0700
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()
{
}
}
.
- Follow-Ups:
- Re: Session object is NULL in HTTP handler
- From: Lucas Tam
- Re: Session object is NULL in HTTP handler
- Prev by Date: Detect click on a link
- Next by Date: Unanswered Questions
- Previous by thread: Detect click on a link
- Next by thread: Re: Session object is NULL in HTTP handler
- Index(es):
Relevant Pages
|