2011-08-14 141 views

回答

1

一般來說你會做這樣的事情:

HttpWebRequest Request = WebRequest.Create(Url) as HttpWebRequest; 
Request.Method = "GET"; //Or PUT, DELETE, POST 
Request.ContentType = "application/x-www-form-urlencoded"; 
using (HttpWebResponse Response = Request.GetResponse() as HttpWebResponse) 
{ 
    if (Response.StatusCode != HttpStatusCode.OK) 
     throw new Exception("The request did not complete successfully and returned status code " + Response.StatusCode); 
    using (StreamReader Reader = new StreamReader(Response.GetResponseStream())) 
    { 
     string ReturnedData=Reader.ReadToEnd(); 
    } 
} 

我沒有混合回報率和C#,但(更不用說JRuby中),但它應該只是一個以上的基本修改。