1
由於某種原因,我不能使用GetRequestStream
或GetResponse
在Silverlight中出現下劃線:S不確定要使用什麼?我試圖連接到我的網絡服務,這裏是我得到的錯誤,GetResponse和GetRequestStream silverlight
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();
有沒有人有解決方法?
Silverlight的版本? 5? – AnthonyWJones 2012-07-24 07:41:46
嗨,是它的5.。 – 2012-07-24 08:35:58