WebRequest POST form containing XML?

outlaw

New Member
I am trying to use .Net WebRequest to POST a form. The form contains fields that are XML. (Among other things) I have tried the following code:\[code\]WebRequest req = WebRequest.Create(ctx.SvcUrl);req.Method = "POST";req.ContentType = "application/x-www-form-urlencoded";using (var writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)){ string reqBody = "first=<bill/>&last=smith"; //(embedded <>) - 500 Internal Server Error writer.Write(reqBody);}rsp = req.GetResponse();var strm = rsp.GetResponseStream();var rdr = new StreamReader(strm);string input = rdr.ReadToEnd();\[/code\]The <> in reqBody causes a 500 - Internal Server error. What's the right way to encode this? Or are multi-part forms the answer??
 
Back
Top