473,508 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTP handlers - Maintaining global objects, and multi-threading

I have an environment with many thousands of client machines uploading
data files several times each day to a web server via HTTP PUT.

To avoid disk I/O (for performance), I am implementing a HTTP handler
to intercept and process incoming data without touching the disk. I
cannot detect PUT requests with my handler (don't know if this is even
supported), so I'm redirecting all requests to the handler as POST
using an ISAPI filter.

I wish to share LDAP and SQL connections across multiple requests (for
performance). Is it possible to maintain global objects in a HTTP
handler (equivalent to global.asax in web applications)?

Files are uploaded through a tree hierarchy, and at the top-level only
a handful of machines upload the files to the topmost web server. I
have no control over these machines, which upload files one at a time.
So I need a way to complete the HTTP request (so the next file can
begin uploading), before the content has been processed. If I create a
new thread from ProcessRequest() to do the processing, and return from
ProcessRequest(), will this:
a) Terminate the new thread - bad
b) Trigger the next HTTP request, but keep the new thread running
c) Wait for the new thread to terminate before triggering the next
HTTP request

Any help is greatly appreciated.

Cheers,
Chris Hughes
Nov 17 '05 #1
5 1990
System.Web.UI.Page is the default HttpHandler for ASP.Net. When you create
an HttpHandler, you are substituting your class for the Page class as the
handler for the request types you specify. As such, you certainly do have
access to all the elements that System.Web.UI.Page has access to, as your
Handler is also running under ASP.Net, and works within the same HttpContext
that a Page class does. In fact, you can use a global.asax file in your app
as well, and access the Application, Cache, and Session, just as you would
with a Page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"Chris Hughes" <Ch**********@managesoft.com> wrote in message
news:77**************************@posting.google.c om...
I have an environment with many thousands of client machines uploading
data files several times each day to a web server via HTTP PUT.

To avoid disk I/O (for performance), I am implementing a HTTP handler
to intercept and process incoming data without touching the disk. I
cannot detect PUT requests with my handler (don't know if this is even
supported), so I'm redirecting all requests to the handler as POST
using an ISAPI filter.

I wish to share LDAP and SQL connections across multiple requests (for
performance). Is it possible to maintain global objects in a HTTP
handler (equivalent to global.asax in web applications)?

Files are uploaded through a tree hierarchy, and at the top-level only
a handful of machines upload the files to the topmost web server. I
have no control over these machines, which upload files one at a time.
So I need a way to complete the HTTP request (so the next file can
begin uploading), before the content has been processed. If I create a
new thread from ProcessRequest() to do the processing, and return from
ProcessRequest(), will this:
a) Terminate the new thread - bad
b) Trigger the next HTTP request, but keep the new thread running
c) Wait for the new thread to terminate before triggering the next
HTTP request

Any help is greatly appreciated.

Cheers,
Chris Hughes

Nov 17 '05 #2
"Chris Hughes" <Ch**********@managesoft.com> wrote in message
news:77**************************@posting.google.c om...
I have an environment with many thousands of client machines uploading
data files several times each day to a web server via HTTP PUT.

To avoid disk I/O (for performance), I am implementing a HTTP handler
to intercept and process incoming data without touching the disk. I
cannot detect PUT requests with my handler (don't know if this is even
supported), so I'm redirecting all requests to the handler as POST
using an ISAPI filter.
I don't know why you wouldn't be able to get PUT requests. Did you specify
PUT as a verb in the <httpHandler> element in web.config?
I wish to share LDAP and SQL connections across multiple requests (for
performance). Is it possible to maintain global objects in a HTTP
handler (equivalent to global.asax in web applications)?
Sure. Just keep the globals in static (Shared in VB) class members. But
you'll have to synchronize access to them, of course. "lock
(typeof(MyHandler))" should do it.
Files are uploaded through a tree hierarchy, and at the top-level only
a handful of machines upload the files to the topmost web server. I
have no control over these machines, which upload files one at a time.
So I need a way to complete the HTTP request (so the next file can
begin uploading), before the content has been processed.


It sounds like you need an asynchronous HTTP Handler. Look up
IHttpAsyncHandler in the documentation.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #3
Thanks for the feedback, John. Very helpful.
To avoid disk I/O (for performance), I am implementing a HTTP handler
to intercept and process incoming data without touching the disk. I
cannot detect PUT requests with my handler (don't know if this is even
supported), so I'm redirecting all requests to the handler as POST
using an ISAPI filter.


I don't know why you wouldn't be able to get PUT requests. Did you specify
PUT as a verb in the <httpHandler> element in web.config?


I set verb="*". I did some searching, and machine.config configures
only HttpGet, HttpPost and HttpSoap requests by default. The
documentation states that this is not extensible for now.

I was told by a Microsoft rep that I can access the data through an
ISAPI extension by using an ISAPI filter to change the HTTP header
from PUT to POST. However, my testing has found that an HTTP handler
does not recognise these changes, and that I might need to use an
ISAPI extension instead, which would be unfortunate.

Any ideas how I might get around this? Is the HTTP handler loaded
before the ISAPI filter is able to change the HTTP header?

Cheers,
Chris Hughes
Nov 17 '05 #4
"Chris Hughes" <Ch**********@managesoft.com> wrote in message
news:77**************************@posting.google.c om...
Thanks for the feedback, John. Very helpful.
To avoid disk I/O (for performance), I am implementing a HTTP handler
to intercept and process incoming data without touching the disk. I
cannot detect PUT requests with my handler (don't know if this is even
supported), so I'm redirecting all requests to the handler as POST
using an ISAPI filter.


I don't know why you wouldn't be able to get PUT requests. Did you specify PUT as a verb in the <httpHandler> element in web.config?


I set verb="*". I did some searching, and machine.config configures
only HttpGet, HttpPost and HttpSoap requests by default. The
documentation states that this is not extensible for now.


You may have misunderstood. "HttpPost" has to do with Web Services. verb="*"
should work. Give it a try. You'll also have to configure IIS to pass that
verb to your handler. Click "Configuration" on the Home Directory tab.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #5
John,
I set verb="*". I did some searching, and machine.config
configures only HttpGet, HttpPost and HttpSoap requests
by default. The documentation states that this is not
extensible for now.


You may have misunderstood. "HttpPost" has to do with
Web Services. verb="*" should work. Give it a try. You'll
also have to configure IIS to pass that verb to your
handler. Click "Configuration" on the Home Directory tab.


This is perfect. I don't have to write any ISAPI dlls. I have tested
your suggestions, and they work great!

Thanks again.

Cheers,
Chris Hughes

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #6

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

Similar topics

10
7738
by: Richard A. DeVenezia | last post by:
At line this.timerId = setInterval (function(){this.step()}, 100) I get error dialog Error:Object doesn't support this property or method. If I change it to this.timerId = setInterval...
10
3561
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
1
3828
by: Nimmi Srivastav | last post by:
There's a rather nondescript book called "Using Borland C++" by Lee and Mark Atkinson (Que Corporation) which presents an excellent discussion of overloaded new and delete operators. In fact there...
7
5211
by: Paul Reddin | last post by:
Hi, Having just upgraded one of our servers to V8.2, the CONTINUE HANDLERs in Stored procedures seem to be behaving differently? i.e Instead of continuing at the next statement (as they did...
0
1156
by: MechSoft | last post by:
Hi, there, I have an issue about globally access data. My multi-threaded application has some resources that need to be accessed by multiple threads and have the lifetime of the application,...
2
2413
by: Norton | last post by:
I understand how to create HTTP modules that can be used to add functionality to a website but there are a few things I don't understand. If I create an HTTP Module and I want it to intercept a...
15
2452
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
16
2480
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some...
30
1926
by: David Mathog | last post by:
Every so often I find a need to move data in or out of functions which are not called directly. For instance, alarm handlers or the compare function used by qsort. In these cases there is no...
3
1636
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
0
7125
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...
0
7328
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
7388
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...
1
7049
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
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.