473,396 Members | 1,864 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,396 software developers and data experts.

Custom HTTPModule - Intercept Session Variable Request

ADN
Hi, I am creating a custom HTTPModule to intercept the request of when
the user is attempting to retrieve a session variable. For instance,
if I set a session variable in my code like so:

session["myString"] = "Hello World";

When the request for that session variable "myString" is attempted to
be retrieved, I would like to intercept that request like so:

if (Request is for session variable "myString")
{
//send this string instead
}

Is it even possible to intercept the request of a session variable in
a custom HTTPModule?
Jun 27 '08 #1
7 4671
My understanding is that a http module is to handle http requests against a
resource. Here it would be rather a session provider :
http://msdn.microsoft.com/en-us/libr...87(VS.80).aspx

It could be also handled at the application level using something such as :
http://www.codeproject.com/KB/aspnet...sionstate.aspx

So that you can have strongly typed state storage and you could change the
underlying store at will including on a value by value basis....

Also you may want to explain what you are trying to do in case someone would
have another approach to suggest...
---
Patrice

"ADN" <vc******@gmail.coma écrit dans le message de groupe de discussion :
e2**********************************...oglegroups.com...
Hi, I am creating a custom HTTPModule to intercept the request of when
the user is attempting to retrieve a session variable. For instance,
if I set a session variable in my code like so:

session["myString"] = "Hello World";

When the request for that session variable "myString" is attempted to
be retrieved, I would like to intercept that request like so:

if (Request is for session variable "myString")
{
//send this string instead
}

Is it even possible to intercept the request of a session variable in
a custom HTTPModule?

Jun 27 '08 #2

If I were faced with a similar issue, I would code up something along these
lines:

http://aspalliance.com/810_Implement...n_Pattern_in_C
and then not code against the Session object directly, but rather through
this library.

Then you could subclass as necessary, or override values as needed.

...
StateManager stateManager =StateManager.Instance;
stateManager.Add("jk","Joydip",State.Session);
if(stateManager.Get("jk",State.Session)!=null) //<<<you
can edit the code here to bring back what you want.




"ADN" <vc******@gmail.comwrote in message
news:e2**********************************@r66g2000 hsg.googlegroups.com...
Hi, I am creating a custom HTTPModule to intercept the request of when
the user is attempting to retrieve a session variable. For instance,
if I set a session variable in my code like so:

session["myString"] = "Hello World";

When the request for that session variable "myString" is attempted to
be retrieved, I would like to intercept that request like so:

if (Request is for session variable "myString")
{
//send this string instead
}

Is it even possible to intercept the request of a session variable in
a custom HTTPModule?

Jun 27 '08 #3
ADN
To add a bit of complexity to this issue, the reason why I wanted to
use the HttpModule approach is because I have to handle this for
only .asp files and not for .NET files. So I was thinking that if I
can just create a custom HttpModule and then configure IIS to use that
module for.asp pages, I could intercept the request.

So basically, session information is stored in .asp pages. I want to
intercept the request when the .asp page attempts to retrieve the
session value for that particular variable.

Would I be able to create a custom session provider and wrap it in my
HttpModule for .asp pages to use? Is this a good approach? Are there
any better approaches to this?

Thanks for all your help!
Jun 27 '08 #4
asp session is plugable (its just a shared memory dll). you can only cjange
asp session behavior by changing your asp pages to use a custom session
manager.

-- bruce (sqlwork.com)
"ADN" wrote:
To add a bit of complexity to this issue, the reason why I wanted to
use the HttpModule approach is because I have to handle this for
only .asp files and not for .NET files. So I was thinking that if I
can just create a custom HttpModule and then configure IIS to use that
module for.asp pages, I could intercept the request.

So basically, session information is stored in .asp pages. I want to
intercept the request when the .asp page attempts to retrieve the
session value for that particular variable.

Would I be able to create a custom session provider and wrap it in my
HttpModule for .asp pages to use? Is this a good approach? Are there
any better approaches to this?

Thanks for all your help!
Jun 27 '08 #5
ADN
Got ya, alright, thank you very much for your help. doesn't look like
I'm going to be able to do it without modifying each of my .asp pages.
Jun 27 '08 #6
The problem you have here is that classic ASP session is a much different
animal than ASP.NET managed session state, so just mapping your .asp pages to
get processed through the ASP.NET runtime isn't going to buy you anything.
You would actually need to replace the classic ASP.DLL non-managed handler.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"ADN" wrote:
To add a bit of complexity to this issue, the reason why I wanted to
use the HttpModule approach is because I have to handle this for
only .asp files and not for .NET files. So I was thinking that if I
can just create a custom HttpModule and then configure IIS to use that
module for.asp pages, I could intercept the request.

So basically, session information is stored in .asp pages. I want to
intercept the request when the .asp page attempts to retrieve the
session value for that particular variable.

Would I be able to create a custom session provider and wrap it in my
HttpModule for .asp pages to use? Is this a good approach? Are there
any better approaches to this?

Thanks for all your help!
Jun 27 '08 #7
You do need to create custom HttpModule for this purpose and you won't be
able to achieve this using that.

What you need to create is SessionStateProvider which implements this
interface.

Remember that ASP.NET 2.0 has a pluggable architecture, you do not need to
intercept anything, just plug your components instead of the default ones.

--
Madhur

"ADN" <vc******@gmail.comwrote in message
news:e2**********************************@r66g2000 hsg.googlegroups.com...
Hi, I am creating a custom HTTPModule to intercept the request of when
the user is attempting to retrieve a session variable. For instance,
if I set a session variable in my code like so:

session["myString"] = "Hello World";

When the request for that session variable "myString" is attempted to
be retrieved, I would like to intercept that request like so:

if (Request is for session variable "myString")
{
//send this string instead
}

Is it even possible to intercept the request of a session variable in
a custom HTTPModule?
Jun 27 '08 #8

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

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
0
by: Joshua Belden | last post by:
I have a custom httpmodule that looks at the HttpApplication.Context.Session.SessionId. I've noticed that it returns a unique SessionId every time, even if the requests are made by the same...
0
by: Cybermedia Marketing | last post by:
I'm trying to convert an ISAPI filter to an httpmodule. The ISAPI filter added custom headers to the response which could later be accessed by the asp page. ISAPI Filter: ...
3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
3
by: David B. Bitton | last post by:
For some odd reason, despite the fact that I assign my own custom IPrincipal to the HttpContext.User property in an HttpApplication.AuthenticateRequest event handler inside of an IHttpModule,...
3
by: Gilles | last post by:
Hi, I'm using a custom HttpModule. Implementation as follow: internal class CustomHtttpModule:IHttpModule { public void Init(HttpApplication app) { app.AuthenticationRequest += new...
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...
1
by: Mike Kline | last post by:
Hi There! How do I make the Objects in the custom made HttpModule available to ASPX page or ASCX controls without requiring an object reference? For example, SessionState HttpModule made the...
0
by: djnokturnal | last post by:
Hey, I am attempting to write an HTTPModule that will intercept requests destined to the https://somesite.com/owa path and route it to a different folder. The problem (I think) is that IIS is...
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: 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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.