Can someone give me a good reference HowTo write out a proper HttpPOST method?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thisismykindabyte
    New Member
    • Oct 2008
    • 9

    Can someone give me a good reference HowTo write out a proper HttpPOST method?

    Hello,

    I was wondering if anyone could refer me to a good website that details what exactly makes up the GET and POST methods of a HttpRequest/Response class?

    Basically, I am trying to figure out how do you POST data to a website. Many examples seem to be using the URL bar for POSTing, like submitting a search to Google for example is something like "Searchstringhe re"&button=clic k if I'm not mistaken. But if I'm not wrong the POST method just sends a string out to google like this ("http://www.google.com/"SearchStringHe re"*button=clic k"). None of this makes sense to me as I thought everything travels as a packet. What if you were trying to enter text into a message board? You wouldn't put the whole message board text string into a POST string, would you? Even if that was the case, how would you go about posting it? I thought (almost every) website was javascripted, does a POST method handle that?

    Basically I don't see the whole picture of whats going on, and not even MSDN is sheding any light on how HttpRequest/HttpResponse actually sends out data with a POST method. If anyone can reference me to a website or a forum response that explains in detail just how C# can send and recieve information with HttpRequest and HttpResponse, it would be very helpful. Thank you!
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Hi there!
    You have a lot of questions!
    Most of these are answered during courses you take at school for web development.

    Originally posted by thisismykindaby te
    Basically, I am trying to figure out how do you POST data to a website...

    But if I'm not wrong the POST method just sends a string out to google like this ("http://www.google.com/"SearchStringHe re"*button=clic k"). Even if that was the case, how would you go about posting it?
    HTTP is a request/response standard between a client (the web browser) and a server. POST is a way your data submitted to the server to be processed. This is outlined in the HTTP protocol. You should research HTTP before attempting to do any web development.

    Originally posted by thisismykindaby te
    ]
    You wouldn't put the whole message board text string into a POST string, would you?
    Simply put: Yes.

    The data that's submitted to the server is anything between <form> tags in the body of the HTML. Not all of the data is submitted to the server. Just the stuff that's important (the Input).

    Originally posted by thisismykindaby te
    ]
    None of this makes sense to me as I thought everything travels as a packet.
    Typically the TCP/IP protocol is used when submitting data to the server. You should research this protocol to understand how the data is transferred to the server.


    Originally posted by thisismykindaby te
    ]
    I thought (almost every) website was javascripted, does a POST method handle that?
    JavaScript is a client side scripting language that lets you preform some functionality in the web browser. It can be used to validate data before sending it to the server, but has nothing to do with the POST method.


    Originally posted by thisismykindaby te
    Basically I don't see the whole picture of whats going on, and not even MSDN is sheding any light on how HttpRequest/HttpResponse actually sends out data with a POST method. If anyone can reference me to a website or a forum response that explains in detail just how C# can send and recieve information with HttpRequest and HttpResponse, it would be very helpful. Thank you!
    I strongly recommend taking a course on web development before tackling these questions.

    -Frinny

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      To help you with your search, you are using a big munged definition of POST. "POST"ed data does not go in the URL, that is the query string.
      Generally you will have one or the other. On a <form> tag you can POST or GET, GET is the way a normal webpage request works, like clicking a link or entering a URL in the bar manually. The values are all contained in the header section of an HTTP request.
      POST sends data as "content", after the HTTP header.
      If you are really curious, I would suggest following frinny's advice and looking up the RFCs for HTTP

      Comment

      • thisismykindabyte
        New Member
        • Oct 2008
        • 9

        #4
        Wow! Thanks! This really helped clear up some of the confusion. I've been looking into HttpRequest/HttpResponse code samples but it was hard to tell what exactly was going on, and I couldn't find good detailed explanations of the big picture, so, thanks again!

        I'd just like to ask (or note) that I've been using Fiddler2, and while I can see (If i'm looking at it correctly) what makes up a Http Get response, I can't for the life of me find any Post responses. Do you guys know if Fiddler supports POSTs, or if there is a better web monitoring program I should be using?

        If not, no big deal, I'm quite happy with the resources and ideas I was pointed too, thanks again!

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Fiddler is just a packet watcher right?
          You should be able to follow the TCP/IP stream and recreate a request.

          Here is an example I pulled from ethereal (modified to hide private-ish data)

          POST Request
          Code:
          POST /customer/customer.cgi?saveSMTPSettings&time=1226585314297 HTTP/1.1
          Accept: */*
          Accept-Language: en-us
          Content-Type: application/x-www-form-urlencoded
          Accept-Encoding: gzip, deflate
          User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
          Host: MyHost
          Content-Length: 137
          Connection: Keep-Alive
          Cache-Control: no-cache
          
          DisplayName=MyHost&EmailAddress=email@domain.com&Server=mail.domain.com&Port=25&Username=username@domain.com&Password=pass&UseAuth=true

          Server Response
          Code:
          HTTP/1.0 200 OK
          Content-Length: 23
          RESPONSE|STATUS=SUCCESS

          Comment

          • thisismykindabyte
            New Member
            • Oct 2008
            • 9

            #6
            YOU are the man!

            Thanks again!

            Comment

            Working...