Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. WebBrowser Control and HTTP requestes to server question

WebBrowser Control and HTTP requestes to server question

Scheduled Pinned Locked Moved C#
questionsysadmin
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Khoramdin
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • K 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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        K Offline
        K Offline
        Khoramdin
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • K Khoramdin

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            K Offline
            K Offline
            Khoramdin
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • K 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

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups