1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C# multipart/form-data

Discussion in 'C, C++, C#' started by kaidoristm, Jan 10, 2010.

  1. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    I need to process an form through multipart/form-data using HttpWebReguest just normal text fields no file upload. This drives me nuts already whatever i do result is wrong. Anyone got any examples maybe?
     
  2. justone

    justone Elite Member

    Joined:
    Oct 12, 2008
    Messages:
    1,516
    Likes Received:
    1,036
    Occupation:
    -
    Location:
    Europe
    There is libcurl for C#
    You might want to look into that, you'll find plenty of examples
     
  3. pyronaut

    pyronaut Executive VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,229
    Likes Received:
    1,422
  4. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Thanks but got solved it already.
    Using Tamper Data for browser and Wireshark for hardware :)

    Thanks for suggestion i have libcurl but wanted to accomplish without it.
    I had small mistake in boundaries fixed it and works now :)
     
  5. divinci

    divinci Junior Member

    Joined:
    Sep 25, 2007
    Messages:
    111
    Likes Received:
    15
    Fiddler 2 is good also - and has a DLL you can plug into.
     
  6. mline

    mline Newbie

    Joined:
    Jan 30, 2010
    Messages:
    49
    Likes Received:
    18
    I personally use a combination of Commview for standard network traffic (your standard http, messaging protocols, etc) and then HttpAnalyzerStandard for anything like HTTPS (SSL) requests. Really any of the other suggestions are good, as well. Just stating my particular preference.
     
  7. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    78
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET
    the mime forms can be a pain in the butt. typically speaking what i do is use commview like line said, then re-create that mime form using string builder (or sometimes just regular string concatenation). then using stream writer to write that to the httpwebrequest output stream.

    just remember to pay close attention to the new line spacing in the form, and to add in your boundary header line to the packet.

    it will take a little trial and error to get it right but with a good packet logger your attention to detail will pay off.