Jump to content

Create A Multipart Form-data Response


aalbetski

Recommended Posts

I need to create an HttpWebResponse usin multipart/form-data. This is what I have so far: StringBuilder sb = new StringBuilder(); sb.Append("--xyz\r\n"); sb.Append("Content-Disposition: form-data; name=\"PayloadType\"\r\n\r\nX12_270_004010X092A1\r\n"); sb.Append("--xyz\r\n"); sb.Append("Content-Disposition: form-data; name=\"ProcessingMode\"\r\n\r\nRealTime\r\n"); sb.Append("--xyz--"); byte[] Postdata = System.Text.Encoding.Default.GetBytes(sb.ToString()); Response.AddHeader("Content-Type", "multipart/form-data; boundary=xyz"); Response.AddHeader("Content-Length", Postdata.Length.ToString()); Response.AddHeader("Content-Encoding", "multipart/form-data"); Response.OutputStream.Write(Postdata, 0, Postdata.Length); Response.End();It just doesn't seem to work. Is the output stream supposed to be part of the header? When I call this from a client, all parts of the response are output to the page. I'm new to multipart and would appreciate any insights

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...