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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...