473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Catching Session start in HTTPModules

Hi,

I'm trying to get away from using global.asax for reasons of
'neatness'.

Am I able to register a HTTPModule that captures the starting of a
user session? Isn't Session_Start an event in global.asax? ... and
isn't global.asax exposing events of HttpApplication?

What am I missing?

Thanks in advance,
Damien

public class clsSessionManager : IHttpModule
{
#region IHttpModule Members

void IHttpModule.Dispose()
{
}

void IHttpModule.Init(HttpApplication context)
{
// I would have thought that I could use
context.SessionStart+= here....
}

#endregion
}
Jul 1 '08 #1
2 2085
I put all kinds of code , static methods and fields in Global.asax and it is
very neat (at least to me).
You can use Session in an HttpModule by implementing the marker interface
IRequiresSessionState.
Peter
"DamienS" <da**********@yahoo.com.auwrote in message
news:5b**********************************@q24g2000 prf.googlegroups.com...
Hi,

I'm trying to get away from using global.asax for reasons of
'neatness'.

Am I able to register a HTTPModule that captures the starting of a
user session? Isn't Session_Start an event in global.asax? ... and
isn't global.asax exposing events of HttpApplication?

What am I missing?

Thanks in advance,
Damien

public class clsSessionManager : IHttpModule
{
#region IHttpModule Members

void IHttpModule.Dispose()
{
}

void IHttpModule.Init(HttpApplication context)
{
// I would have thought that I could use
context.SessionStart+= here....
}

#endregion
}
Jul 1 '08 #2
Thanks very much Peter.

I'm having trouble finding the session_start event though. It appears
in global.asax, however I can't find any other reference to it in the
framework. I've read up on IRequiresSessionState and understand that I
can use it to see if the current context requires a session, however
what I'm trying to do is capture when a session begins. Is there any
way to do this outside of global.asax?

After digging around some more, I'm now really curious - 'where' is
the session_start event in global.asax defined? Why doesn't it appear
in the object model? I notice that there's a AcquireRequestState event
on HttpApplication described as "Occurs when ASP.NET acquires the
current state (for example, session state) that is associated with the
current request." - however, to me, this description doesn't say that
it fires when a new session is created.

Thanks in advance,
Damien


On Jul 1, 1:07*pm, "Peter Bromberg [C# MVP]"
<pbromb...@nospamDood.yahoo.comwrote:
I put all kinds of code , static methods and fields in Global.asax and it is
very neat (at least to me).
You can useSessionin an HttpModule by implementing the marker interface
IRequiresSessionState.
Peter"DamienS" <damiensaw...@yahoo.com.auwrote in message

news:5b**********************************@q24g2000 prf.googlegroups.com...
Hi,
I'm trying to get away from using global.asax for reasons of
'neatness'.
Am I able to register a HTTPModule that captures the starting of a
usersession? Isn't Session_Start an event in global.asax? ... and
isn't global.asax exposing events of HttpApplication?
What am I missing?
Thanks in advance,
Damien
public class clsSessionManager : IHttpModule
* *{
* * * *#region IHttpModule Members
* * * *void IHttpModule.Dispose()
* * * *{
* * * *}
* * * *void IHttpModule.Init(HttpApplication context)
* * * *{
* * * * * // I would have thought that I could use
context.SessionStart+= here....
* * * *}
* * * *#endregion
* *}- Hide quoted text -

- Show quoted text -
Jul 1 '08 #3

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

Similar topics

2
by: Aurel | last post by:
Hi, I have create a httpmodule but I have some problems. I can't access to the session. Even if I create my class like this public class myModule: IHttpModule, IRequiresSessionState {} ...
4
by: John Q. Smith | last post by:
I'm trying to find out some of the details behind OOP state management with SQL Server. For instance - how long does the session object live on any server? Is it created and destoyed with each...
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...
4
by: Danny W | last post by:
Hi There! Is it possible to use HttpModule to replace the built-in ASP.NET Session object? I want to write a HttpModule that will handle storing and retrieving of session values from an external...
11
by: Markus Kling | last post by:
Hi, I have a web application that has two sub-applications. The root application defines two httpModules which shall not be loaded for the subapplications. I tried to achieve this by adding ...
6
by: KevinGravelle | last post by:
What is wrong with this picture? I'm trying to set my shopping cart text on my home page using the following function that is executed when the class is constructed: protected string...
2
by: fniles | last post by:
I am using Visual Studio 2005. In my ASPX page, when I try to use Session, I got the error "Session state can only be used when enableSessionState is set to true, either in a configuration file or...
10
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I've been on this for a while, and cannot figure it out. Can someone please help with this message? SessionState can only be used when EnableSessionState is set to true, either in a...
4
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.