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

HTTP Modules

If I were writing an HTTP module where I wanted to access the response text
that was being sent back to the user, what would be the optimum method for
doing this within the module? I'm investigating the viability of using this
for logging some info, and I'm wondering if there are any established or
best practice methods for doing this that will minimise the performance hit
on the server?

Regards,

Tim.
Nov 19 '05 #1
9 1550
Tim:

DinoE has a good article on this topic:

MyTracer Monitors and Traces ASP.NET Apps
http://msdn.microsoft.com/msdnmag/is...4/cuttingedge/

--
Scott
http://www.OdeToCode.com/blogs/scott/
If I were writing an HTTP module where I wanted to access the response
text that was being sent back to the user, what would be the optimum
method for doing this within the module? I'm investigating the
viability of using this for logging some info, and I'm wondering if
there are any established or best practice methods for doing this that
will minimise the performance hit on the server?

Regards,

Tim.

Nov 19 '05 #2
Hi Scott,

Thanks for the link, I don't think it's quite what I'm looking for.......
Basically what I need to be able to do is intercept the response text being
sent back to the user after their web request has been processed, to parse
through looking for specific information in the response text, which will
then be logged to a database or log file. I think the way to do this would
be with a HTTP Module (so I can do it on all pages and easily deploy the
solution on several sites), utitlising a HTTP filter so I can access the
final response.text. What I'm interested in knowing is if there is an
optimum way to achieve this, keeping the additional overhead as low as
possible. Basically I'm doing a proof of concept in C# to see how well it
performs and to see if the overhead is acceptable enough to not need to have
to write an ISAPI filter instead.

Regards,

Tim.
Nov 19 '05 #3
Hi Tim:

Ah yes, I think I see now. I know I've read an article on the topic but I
can't seem to find it now. I'm sure the code was using an HTTP Module and
hooking the EndRequest event. I know one potential problem with EndRequest
is that it will not fire if you have Response.Redirect or Server.Transfer
in you code the event will be missed. Personally I'd try to keep this in
managed code, ISAPI filters were hard to debug and configure.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Hi Scott,

Thanks for the link, I don't think it's quite what I'm looking
for....... Basically what I need to be able to do is intercept the
response text being sent back to the user after their web request has
been processed, to parse through looking for specific information in
the response text, which will then be logged to a database or log
file. I think the way to do this would be with a HTTP Module (so I can
do it on all pages and easily deploy the solution on several sites),
utitlising a HTTP filter so I can access the final response.text. What
I'm interested in knowing is if there is an optimum way to achieve
this, keeping the additional overhead as low as possible. Basically
I'm doing a proof of concept in C# to see how well it performs and to
see if the overhead is acceptable enough to not need to have to write
an ISAPI filter instead.

Regards,

Tim.

Nov 19 '05 #4
If your doing this via n ihttpmodule then you need to hook into the
response.filter, its gives access to the response text as a binary stream
which you need to convert to a string to work with, and then back again to
binary before forwarding your finalized response out.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Scott Allen" <sc***@nospam.OdeToCode.com> wrote in message
news:39*********************@msnews.microsoft.com. ..
Hi Tim:

Ah yes, I think I see now. I know I've read an article on the topic but I
can't seem to find it now. I'm sure the code was using an HTTP Module and
hooking the EndRequest event. I know one potential problem with EndRequest
is that it will not fire if you have Response.Redirect or Server.Transfer
in you code the event will be missed. Personally I'd try to keep this in
managed code, ISAPI filters were hard to debug and configure.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Hi Scott,

Thanks for the link, I don't think it's quite what I'm looking
for....... Basically what I need to be able to do is intercept the
response text being sent back to the user after their web request has
been processed, to parse through looking for specific information in
the response text, which will then be logged to a database or log
file. I think the way to do this would be with a HTTP Module (so I can
do it on all pages and easily deploy the solution on several sites),
utitlising a HTTP filter so I can access the final response.text. What
I'm interested in knowing is if there is an optimum way to achieve
this, keeping the additional overhead as low as possible. Basically
I'm doing a proof of concept in C# to see how well it performs and to
see if the overhead is acceptable enough to not need to have to write
an ISAPI filter instead.

Regards,

Tim.


Nov 19 '05 #5
See httpResponse.Filter that allows to define a stream that will receive
what is written to httpResponse...

You could also explain what exactly you try to capture to see if someone
could come up with another approach to perform the same job...

Patrice
--

"Tim Payne" <ti*@branded3.com> a écrit dans le message de
news:OC*************@TK2MSFTNGP12.phx.gbl...
Hi Scott,

Thanks for the link, I don't think it's quite what I'm looking for.......
Basically what I need to be able to do is intercept the response text being sent back to the user after their web request has been processed, to parse
through looking for specific information in the response text, which will
then be logged to a database or log file. I think the way to do this would
be with a HTTP Module (so I can do it on all pages and easily deploy the
solution on several sites), utitlising a HTTP filter so I can access the
final response.text. What I'm interested in knowing is if there is an
optimum way to achieve this, keeping the additional overhead as low as
possible. Basically I'm doing a proof of concept in C# to see how well it
performs and to see if the overhead is acceptable enough to not need to have to write an ISAPI filter instead.

Regards,

Tim.

Nov 19 '05 #6
I've managed to get a working concept up and running using a HTTP Module and
a HTTP Filter, as per the suggestion of several of the poepl who have
replied here. Basically, what the system does is look through the response
text for specific tracking tags and logs them into a database. It doesn't
actually modify the text, so all I'm doing is converting the bits to a text
string, parsing out the tags and logging them if they're present, and then
carrying on with the response as normal (after cleaning up all the
connection objects etc). It seems to woork ok, the only odd issue that I've
noticed is that under stress, using ACT, I get a fairly high number of 401
errors on all of the aspx pages, even though no authentication is being
used, and the same pages ran error free under the same load without the
module in place. Does anyone know what could be causing this to happen? My
initial gues is that it could be some kind of ado.net issue.......

Thanks for all the advice so far guys!

Regards,

Tim.
Nov 19 '05 #7
How are those tracking tags created ? Perhaps could they be recorded at the
source.

For the specific problem, are you using "no authentication" or are you using
"Integrated Window Authentication" on your dev machine ? If the later, try
http://support.microsoft.com/kb/322032/en-us

Patrice

--

"Tim Payne" <ti*@branded3.com> a écrit dans le message de
news:us**************@TK2MSFTNGP14.phx.gbl...
I've managed to get a working concept up and running using a HTTP Module and a HTTP Filter, as per the suggestion of several of the poepl who have
replied here. Basically, what the system does is look through the response
text for specific tracking tags and logs them into a database. It doesn't
actually modify the text, so all I'm doing is converting the bits to a text string, parsing out the tags and logging them if they're present, and then
carrying on with the response as normal (after cleaning up all the
connection objects etc). It seems to woork ok, the only odd issue that I've noticed is that under stress, using ACT, I get a fairly high number of 401
errors on all of the aspx pages, even though no authentication is being
used, and the same pages ran error free under the same load without the
module in place. Does anyone know what could be causing this to happen? My
initial gues is that it could be some kind of ado.net issue.......

Thanks for all the advice so far guys!

Regards,

Tim.

Nov 19 '05 #8
No problem - John got the piece I couldn't remember with Response.Filter.
--
Scott
http://www.OdeToCode.com/blogs/scott/
I've managed to get a working concept up and running using a HTTP
Module and a HTTP Filter, as per the suggestion of several of the
poepl who have replied here. Basically, what the system does is look
through the response text for specific tracking tags and logs them
into a database. It doesn't actually modify the text, so all I'm doing
is converting the bits to a text string, parsing out the tags and
logging them if they're present, and then carrying on with the
response as normal (after cleaning up all the connection objects etc).
It seems to woork ok, the only odd issue that I've noticed is that
under stress, using ACT, I get a fairly high number of 401 errors on
all of the aspx pages, even though no authentication is being used,
and the same pages ran error free under the same load without the
module in place. Does anyone know what could be causing this to
happen? My initial gues is that it could be some kind of ado.net
issue.......

Thanks for all the advice so far guys!

Regards,

Tim.

Nov 19 '05 #9

The sheer amount of errors you are recieving are how the stream is being
sent. If you put a breakpoint in your ReleaseRequestState, you will
notice that it stops multiple times. It sends in ~ 32k packets for the
page. So if you page is a larger size it will send multiple times. If
your doing logic on your context, or something that is not available at
that time you will get a Null Reference error. It just wont crash =).

Toss in a check If Context is null before using it. It should stop some
of the errors

--
DustinFrenton
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jun 1 '06 #10

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

Similar topics

2
by: Pierre Quentel | last post by:
Python standard library provides two modules for asynchronous socket programming : asyncore and asynchat. Several web servers have been built upon these modules (medusa being the best-known I...
2
by: Dave | last post by:
Hi Everyone, I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called...
2
by: Robin Becker | last post by:
We had some legacy applications that used import to get parts of documents in. When run separately these worked fine, but failed when run as a single process because they both imported ch1 (after...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
3
by: PCC | last post by:
I need to be able to redirect web requests from certain parties to specific content. In the old days I would have used ISAPI to do this. Now days I am wondering if I should be doing this using...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
1
by: zpinhead | last post by:
I am unable to get my downloaded extension from pecl to link up with php properly. seems like the php.so I could not use pear install http. pear claimed the extension was already installed....
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.