Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Custom HTTPModule - Intercept Session Variable Request

Reply
Thread Tools

Custom HTTPModule - Intercept Session Variable Request

 
 
ADN
Guest
Posts: n/a
 
      05-05-2008
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?
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      05-05-2008

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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?



 
Reply With Quote
 
 
 
 
ADN
Guest
Posts: n/a
 
      05-05-2008
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!
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      05-05-2008
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!
>

 
Reply With Quote
 
ADN
Guest
Posts: n/a
 
      05-05-2008
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.
 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      05-05-2008
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!
>

 
Reply With Quote
 
Madhur
Guest
Posts: n/a
 
      05-05-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Intercept a request with a protocol different from http =?Utf-8?B?TWF1cml6aW8gUG9sZXR0bw==?= ASP .Net 1 08-23-2006 05:03 PM
Intercept request calls in any application with a windows service? Luis Esteban Valencia ASP .Net 0 07-08-2005 07:17 PM
HELP: intercept request and redirect before page is laoded super todd ASP .Net 1 05-23-2005 10:10 PM
Can you intercept the url request before a 404 error occurs? =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?= ASP .Net 1 07-14-2004 02:45 PM
HttpModule -- how to intercept urls like http://localhost/abc/def or http://localhost/abc/def/ where abc, def are non virtual dir Jiong Feng ASP .Net 0 11-19-2003 05:29 AM



Advertisments