出于某种原因,我无法使用GetRequestStream
或GetResponse
在 Silverlight 中出现下划线:S 不确定要使用什么?我正在尝试连接到我的网络服务,这是我得到错误的地方,
string uri = "http://localhost:8002/Service/Customer";
StringBuilder sb = new StringBuilder();
sb.Append("<Customer>");
sb.AppendLine("<FirstName>" + this.textBox1.Text + "</FirstName>");
sb.AppendLine("<LastName>" + this.textBox2.Text + "</LastName>");
sb.AppendLine("</Customer>");
string NewCustomer = sb.ToString();
byte[] arr = Encoding.UTF8.GetBytes(NewCustomer );
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "application/xml";
req.ContentLength = arr.Length;
Stream reqStrm = req.GetRequestStream();// error here GetRequestStream
reqStrm.Write(arr, 0, arr.Length);
reqStrm.Close();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); //error here GetRequestStream
MessageBox.Show("Staff Creation: Status " + resp.StatusDescription);
reqStrm.Close();
resp.Close();
有人有解决方法吗?