Jump to content

Create A Multipart Form-data Response

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

Edited by aalbetski
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...