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

Events in HttpModule

Hi,

I've easily implemented an HttpModule and use AcquireRequestState to
initialize an object and ReleaseRequestState store to session. Unfortunately
if a Response.Redirect takes place. The ReleaseRequestState does not fire.
No problem, I implement PreSendRequestContent or PreSendRequestHeaders and
now I'm able to fire the event before the Response.Redirect. But Uhoh, I've
got no access to the Session or Context.Items objects???

Please help I'm stumped on when/where to fire an event and still have access
to session and context before firing response.redirect.

Thanks,
John Haynes

jhaynes "at" mckinleycapital "dot" com
Nov 18 '05 #1
2 2700
Hi,

the source parameter holds HttpApplication so you can get context from
it :

public void Init(HttpApplication application)
{
application.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
application.EndRequest += (new
EventHandler(this.Application_EndRequest));
application.PreSendRequestContent += (new EventHandler(this.App));
}

private void App(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
}

anyway you can also use EndRequest.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Getting to the context or session is not the problem, the problem is they no
longer exist at that point in the HttpPipeline they've already been dumped
from the HttpContext...

They are null nothing do not exists at this point. In debug mode when ">?
HttpContext", Current, Session and a few other elements have already been
dumped. As simple as it may seem I have no access to those elements at that
point. At runtime it produces object not found errors

I'd like to find some actual documentation that details what happens when
the events in the pipeline get bypassed. For example. I was using
ReleaseRequestState but Response.Redirect never fires ReleaseRequestState
and goes right to the next page. Where AcquireRequesState will fire. On a
full page load I can run ReleaseRequestState and have full access to Context
and Session but the peculiar thing is PreSendRequestContent and
PreSendRequestHeader preceed ReleaseRequestState in the HttpPipeline yet I
dont have access to the Context or Session there. I have been unable to find
documentation that supports this.

Thanks for the info though.

John

"Natty Gur" <na***@dao2com.com> wrote in message
news:eV*************@TK2MSFTNGP10.phx.gbl...
Hi,

the source parameter holds HttpApplication so you can get context from
it :

public void Init(HttpApplication application)
{
application.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
application.EndRequest += (new
EventHandler(this.Application_EndRequest));
application.PreSendRequestContent += (new EventHandler(this.App));
}

private void App(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
}

anyway you can also use EndRequest.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

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

Similar topics

0
by: shiv | last post by:
hi all, I need to access some variables which are generated in preRequestHandler Event in httpModule. I need these variables in Page ButtonControl Click event. Is that possible? I don't want...
2
by: Holly Li | last post by:
Hi, I am following the example in .net's help doc--"Securing XML Web Services Created Using ASP.NET" I have copied all the code from the example but couldn't make it to work. The problem is that...
7
by: nail | last post by:
Folks, I develop a HttpModule and it works correct, but one problem is occurs. After I register the httpmodule in the web.config, my pages (not testing http://localhost/site but...
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...
0
by: Stefano | last post by:
Hi all, I need to define an application wide custom event, and handle it into an HttpModule. I created a class, with a statis "Current" property. This property returns the instance of the...
2
by: walter | last post by:
Hi there, I know there is pool of HttpApplications, and for each request coming in, HttpRuntime will dedicate one from pool to serve the request. My questions are : 1. since HttpModule is plug...
1
by: Faraz | last post by:
Hi everyone, I am running into a slight problem. My understanding is that a custom HttpModule will run for every request made to the server, regardless of the extension. I do not experience this...
0
by: mattdev1000 | last post by:
Hello, I have an HttpModule that uses a lazy fetch to a secondary tier for calculating some values (the calculation is can be multisecond in the worse case). The HttpModule spins up a thread to...
3
by: Joseph Geretz | last post by:
I'm implementing a web application whose purpose in life is to act as a data conduit. Data is posted to my Web app in XML format, my application examines the data and forwards it onward by posting...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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...

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.