WebBrowser Control and HTTP requestes to server question
-
Hello everyone, I am using WebBrowser Control and when I check all the supported properties, methods, and events associated with the WebBrowser and InternetExplorer objects; I don't see anything that can be used to catch the HTTP requests! I am able to get the URL address for a website using DocumentComplete (Fires when a document is completely loaded and initialized) or get the Client Entered information such as username, password and so on using BeforeNavigate2 (Fires before navigation occurs in the given object. My undrestanding is that for every object such as images a HTTP request is sent to the server. Then the question is how can I get/monitor all these requests? Any information on this is greatly appriciated. Thank you and have a great day. Khoramdin
-
Hello everyone, I am using WebBrowser Control and when I check all the supported properties, methods, and events associated with the WebBrowser and InternetExplorer objects; I don't see anything that can be used to catch the HTTP requests! I am able to get the URL address for a website using DocumentComplete (Fires when a document is completely loaded and initialized) or get the Client Entered information such as username, password and so on using BeforeNavigate2 (Fires before navigation occurs in the given object. My undrestanding is that for every object such as images a HTTP request is sent to the server. Then the question is how can I get/monitor all these requests? Any information on this is greatly appriciated. Thank you and have a great day. Khoramdin
Khoramdin wrote:
My undrestanding is that for every object such as images a HTTP request is sent to the server. Then the question is how can I get/monitor all these requests?
Using the properties and methods exposed by the WebBrowser control - you don't. It doesn't fire these events on an object-by-object basis. They only work on a page-by-page basis. If you want to capture all of this stuff, you'll need to build yourself a proxy server to capture it. All the request, object-by-object, will go through the proxy.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Khoramdin wrote:
My undrestanding is that for every object such as images a HTTP request is sent to the server. Then the question is how can I get/monitor all these requests?
Using the properties and methods exposed by the WebBrowser control - you don't. It doesn't fire these events on an object-by-object basis. They only work on a page-by-page basis. If you want to capture all of this stuff, you'll need to build yourself a proxy server to capture it. All the request, object-by-object, will go through the proxy.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Hello david, Thank you for your reply. I am also wroking on a HTTP Sniffer which and after I create a socket using the Socket class as following:
mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
After I receive the packets, I try to analyze it by first placing the packet in memory. The packets are sorted based on thier ProtocalType into TCP, UDP and I am able to get information such as Version, HeaderLength, TotalLength, and so on for both the protocals. My question is where should I look to get the URL address of the HTTP requests? If I am not mistaken the information should be available in HTTP Header rather than IP Header, TCP Header, or UDP Header! Am I on the right track or I am way off and need to re-think this? Any information on this, is grealy appriciated Dave. As always, thank you so much for your help and have a wonderful day. Khoramddin
-
Hello david, Thank you for your reply. I am also wroking on a HTTP Sniffer which and after I create a socket using the Socket class as following:
mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
After I receive the packets, I try to analyze it by first placing the packet in memory. The packets are sorted based on thier ProtocalType into TCP, UDP and I am able to get information such as Version, HeaderLength, TotalLength, and so on for both the protocals. My question is where should I look to get the URL address of the HTTP requests? If I am not mistaken the information should be available in HTTP Header rather than IP Header, TCP Header, or UDP Header! Am I on the right track or I am way off and need to re-think this? Any information on this, is grealy appriciated Dave. As always, thank you so much for your help and have a wonderful day. Khoramddin
Wow. You've gone from simply using a WebBrowser control to writing your own sniffer in one post.
Khoramdin wrote:
My question is where should I look to get the URL address of the HTTP requests?
None of the headers will contain this. It'll be in the TCP packet data. You may have to string multiple packets together to get the entire request URL.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Wow. You've gone from simply using a WebBrowser control to writing your own sniffer in one post.
Khoramdin wrote:
My question is where should I look to get the URL address of the HTTP requests?
None of the headers will contain this. It'll be in the TCP packet data. You may have to string multiple packets together to get the entire request URL.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007No, I started the work on BHO and then when I couldn't get the HTTP request moved to HTTP Sniffer. Then I heard from someone that I should be able to capture the HTTP requests using the BHO and that is why I thought to come and ask since when I looked for information about that, I could not find any. I wish I was that clever, mate! :laugh: The HTTP sniffer that I managed to put together is based on many articles that I found online such as http://www.c-sharpcorner.com/UploadFile/leonidmolochniy/SimpleSnifferInCS11222005232804PM/SimpleSnifferInCS.aspx[^] Regarding what you said about URL address in TCP. If each packet doesn't hold all the information the how do they know where to start and where to end regarding the connection and file transformation? Thank you, Khoramdin
-
No, I started the work on BHO and then when I couldn't get the HTTP request moved to HTTP Sniffer. Then I heard from someone that I should be able to capture the HTTP requests using the BHO and that is why I thought to come and ask since when I looked for information about that, I could not find any. I wish I was that clever, mate! :laugh: The HTTP sniffer that I managed to put together is based on many articles that I found online such as http://www.c-sharpcorner.com/UploadFile/leonidmolochniy/SimpleSnifferInCS11222005232804PM/SimpleSnifferInCS.aspx[^] Regarding what you said about URL address in TCP. If each packet doesn't hold all the information the how do they know where to start and where to end regarding the connection and file transformation? Thank you, Khoramdin
TCP is the transport protocol. It doesn't have anything to do with actually making the request. All it does is make sure that the "request message" makes it to the destination IP. If the message is too big for a single packet, the message is broken up into multiple packets until the entire message is sent. It's up to the receiving side to rebuild the message using all of the packets involved in it. TCP makes every attempt to get the entire message to the destination and get the packets reassembled in the correct order. HTTP is the messaging protocol. This is what is making the requests and processing the returned data. It doesn't care that TCP is carrying the message. If you were so inclined, you could transport the request and response messages on SneakerNet and floppies if you built the correct drivers for it on each end of the connection.
Khoramdin wrote:
how do they know where to start and where to end regarding the connection and file transformation?
By interpreting the data in each TCP packet. You have to have an in-depth knowledge of HTTP to do this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007