HTTPhandlers
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

daFou (VIP)
Hi ALl,

How do I prevent the ProcessRequest method from the IHttpHandler Class from
closing the http connection and killing the context after the ProcessRequest
method has ended.

TO further explain what I want please read this link:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21129241.html
Reply to this message...
 
    
John Saunders
"daFou" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]


Q: How do I prevent ProcessRequest from closing the connection when it's
done?
A: You don't

ASP.NET doesn't work that way. It's all about request/response. Once the
response has been sent, the request is over and gone, as though it had never
existed (except for anything persistent which the request may have done).

If you need to keep connections open for an indefinite period of time, then
you need to stop using ASP.NET.
--
John Saunders
johnwsaundersiii at hotmail

Reply to this message...
 
    
Girish bharadwaj
If you look at the help for HttpContext: " Encapsulates all HTTP-specific
information about an individual HTTP request. ". By definition, Context is
only per request. If you want more that information or want to do something
across invocations, you might have to consider some of the state management
schemes presented by ASP.NET such as Cookies, ViewState, Session
,Application or Cache.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"John Saunders" <Click here to reveal e-mail address> wrote in message
news:%238$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
daFou (VIP)
I NEED to maintain an active connection to be able to create an efficient
chat application on port 80 without the use of flash or java or active x.
Please read this link:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21129241.html
It explains what I want to do.

It comes down to that I have written this very efficient DHTML chat server
that maintains an active connection with the browser. But I use a TcpListener
to make it work and this means I cannot have the DHTML server work on port 80.
So I figured to use HTTPhandler to intercept certain requests on port 80 and
pass them to the DHTMLchatServer.

Any advice would be welcome

"Girish bharadwaj" wrote:

[Original message clipped]

Reply to this message...
 
    
Richard Blewett [DevelopMentor] (VIP)
What you NEED and whether the communications protocol you have selected can support it are two different issues.

HTTP is a stateless protocol. You cannot keep connections open over long periods (keep-alives are not desined for this).

So sorry, you cannot toake the approach you want with HTTP

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<Click here to reveal e-mail address>

I NEED to maintain an active connection to be able to create an efficient
chat application on port 80 without the use of flash or java or active x.
Please read this link: http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21129241.html
It explains what I want to do.

It comes down to that I have written this very efficient DHTML chat server
that maintains an active connection with the browser. But I use a TcpListener
to make it work and this means I cannot have the DHTML server work on port 80.
So I figured to use HTTPhandler to intercept certain requests on port 80 and
pass them to the DHTMLchatServer.

Any advice would be welcome

"Girish bharadwaj" wrote:

[Original message clipped]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.framework]
Reply to this message...
 
    
Girish Bharadwaj
One thing you can probably do is to have a different port based server to
which you make the request to do the connection with the user and maintain
that connection. But, as Richard says, you cannot get there from here.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Richard Blewett [DevelopMentor]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> What you NEED and whether the communications protocol you have selected
can support it are two different issues.
[Original message clipped]

Reply to this message...
 
    
daFou (VIP)
My chat server does work on any other port that is not already in use. So
debates weather or not HTTP is a suitable protocol is not what I am looking
for.
I need to know how I can have a TcpListener listen on port 80 eventhough IIS
or any other process is listening on that port.. If that is not possible then
I need an HTTPhandler to send a HTTPrequest to another program where it can
be stored.

One way of doing that might be to never letting the ProcesRequest Method end
using some kind of sleep method.

anyways please think along with me.

Regards

"Girish Bharadwaj" wrote:

[Original message clipped]

Reply to this message...
 
    
Richard Blewett [DevelopMentor] (VIP)
What do you want the second HttpRequest to store? I'm a bit confused.

As far as not letting the ProcessRequest method end ... this will block an ASP.NET thread and before long all the ASP.NET threads will be blocked by your Chat Application. At this point ASP.NET will decide that the worker process has become unstable and will recycle it killing all state cached in memory. So I doubt this solution will be one that has much mileage in it.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<Click here to reveal e-mail address>

My chat server does work on any other port that is not already in use. So
debates weather or not HTTP is a suitable protocol is not what I am looking
for.
I need to know how I can have a TcpListener listen on port 80 eventhough IIS
or any other process is listening on that port.. If that is not possible then
I need an HTTPhandler to send a HTTPrequest to another program where it can
be stored.

One way of doing that might be to never letting the ProcesRequest Method end
using some kind of sleep method.

anyways please think along with me.

Regards

"Girish Bharadwaj" wrote:

[Original message clipped]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.framework]
Reply to this message...
 
    
daFou (VIP)
As I explan in the link I provided I CAN keep the connection open using the
HTTP protcol. HTTP is nothing more then a pre defined set of commands so HTTP
in itself is not stateless. I am not looking to debate wether my ChatServer
works or not because it does work.
The only problem I have is I use a TcpListener and I cannot use that on port
80 becuase IIS is already listening on that port and I need my program to
work on port 80.

"Girish Bharadwaj" wrote:

[Original message clipped]

Reply to this message...
 
    
Richard Blewett [DevelopMentor] (VIP)
The link you provided does not explain how to hold a connection open over HTTP - unless the answers to the query do, but this requires a subscription which I'm not prepared to pay. Is there any other way for me to be able to see the technique that keeps an HTTP based connection active over a long period? As far as I know, any HTTP server is going to nuke the connection from the server side after about 30 seconds of inactivity.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<Click here to reveal e-mail address>

As I explan in the link I provided I CAN keep the connection open using the
HTTP protcol. HTTP is nothing more then a pre defined set of commands so HTTP
in itself is not stateless. I am not looking to debate wether my ChatServer
works or not because it does work.
The only problem I have is I use a TcpListener and I cannot use that on port
80 becuase IIS is already listening on that port and I need my program to
work on port 80.

"Girish Bharadwaj" wrote:

[Original message clipped]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.framework]
Reply to this message...
 
    
daFou (VIP)
Richard,

Excactly how I keep the connection alive for indefenet is not important for
my problem. If you are interested to learn how I do it we can engage in a
seperate discusion about this after I solved my problem.

My problem is that I use a TcpListener on what ever port is not in use. But
some users can't use many ports other then 80. When I try to have the
TcpListener listen on port 80 I get this error stating that port is already
in use or something.
This is totally bogus and thus I thought of using HTTPhandlers to redirect
incomming requests and store them.
Some request get redirected and others are left to any other process that
wants them like IIS or some other web server.

I really dont feel like lower level c++ winsock programming and want a clean
way of doing this.

Regards,

DaFou
"Richard Blewett [DevelopMentor]" wrote:

[Original message clipped]

Reply to this message...
 
    
Richard Blewett [DevelopMentor] (VIP)
Not being able to listen on a port that another process is listening on is just the way it works - the only way they have managed to get more then one process on port 80 in XP SP2 and Win2003 is to have a kernel mode driver (http.sys) listen on port 80 and dispatch HTTP traffic to the various user mode processes.

Think of it this way: the port is like a door into a house. You are trying to build another house where one already exists. The http.sys solution is like having the main doorway into a block of flats which is fine as long as you obey the rules of the block's landlord (i.e. you only use HTTP).

So my understanding of what you are tryinng to achieve in terms of the actual application (as opposed to any particular implementation) is to have a web based chat program that is accessible from a browser. You connect to the "server" and I assume you log on in some way so you can be identified in the conversation. The server then "delivers" the messages in the conversation to each of the clients.

ls this the application you are building (or some variant of it)?

Regards

RIchard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<Click here to reveal e-mail address>

Richard,

Excactly how I keep the connection alive for indefenet is not important for
my problem. If you are interested to learn how I do it we can engage in a
seperate discusion about this after I solved my problem.

My problem is that I use a TcpListener on what ever port is not in use. But
some users can't use many ports other then 80. When I try to have the
TcpListener listen on port 80 I get this error stating that port is already
in use or something.
This is totally bogus and thus I thought of using HTTPhandlers to redirect
incomming requests and store them.
Some request get redirected and others are left to any other process that
wants them like IIS or some other web server.

I really dont feel like lower level c++ winsock programming and want a clean
way of doing this.

Regards,

DaFou
"Richard Blewett [DevelopMentor]" wrote:

[Original message clipped]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.framework]
Reply to this message...
 
    
daFou (VIP)
With a little help of you colegue Marvin Smit ( I used to work with him in
several companies ) I created this ultra efficient chat app. No Flash, No
Java, No ActiveX No Reloading and Maximum performance. It works like a charm
but not on port 80.

I know it is possible to intercept incomming requests on any port and
determine what to do with them. Conside a software firewall for instance like
zonealarm. THey do excactly what I want to do only different :-)
But I dont want to getinto the lower lvl c++ winsock hooking and am looking
to solve my problem on a less teadious method.

I'd love for you to involve some of your fellow teachers at developmentor
because this sounds like it could use some attention this matter.

Regards

"Richard Blewett [DevelopMentor]" wrote:

[Original message clipped]

Reply to this message...
 
    
Girish Bharadwaj
Umm, I dont think it works that way. HttpContext is transient. It can only
exists in the context of the ,..umm.. Current request.
See the Architecture overview of how IIS works:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/iisarchitectureoverview.asp

Anyway, I think you should probably consider coding it at lower C++ level
(may be at the sockets level). I dont think HttpHandlers are capable of
doing this.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"daFou" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

subscription which I'm not prepared to pay. Is there any other way for me to
be able to see the technique that keeps an HTTP based connection active over
a long period? As far as I know, any HTTP server is going to nuke the
connection from the server side after about 30 seconds of inactivity.
[Original message clipped]

Reply to this message...
 
 
System.Net.Sockets.TcpListener
System.Web.HttpContext
System.Web.HttpRequest
System.Web.IHttpHandler




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com