Http Post in C#
-
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
-
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
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![^]