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. Http Post in C#

Http Post in C#

Scheduled Pinned Locked Moved C#
csharp
2 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.
  • A Offline
    A Offline
    aruna_koride
    wrote on last edited by
    #1

    Hi I am trying to upload file using Http Post, I need to set content type-multipart.Please advise.. I tried many ways but not succesful.. Thanks

    J 1 Reply Last reply
    0
    • A aruna_koride

      Hi I am trying to upload file using Http Post, I need to set content type-multipart.Please advise.. I tried many ways but not succesful.. Thanks

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      Is this in a browser scenario, or is this in a desktop scenario? With ASP.NET, the best way to upload a file is with the FileUpload control. In a desktop situation, use WebRequest.Create() to create a web request. Set the ContentType property on the request, and then get a response for it:

      WebRequest request= WebRequest.Create(url);
      request.ContentType="multipart/form-data";
      request.Method="POST";
      Stream stream=request.GetRequestStream();
      //write to the stream...
      WebResponse response= request.GetResponse();
      //check the response to see if the file was uploaded successfully

      --Justin Microsoft MVP, C#

      C# / Web / VG.net / MyXaml expert currently looking for (telecommute) contract work![^]

      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