0
如何在Silverlight中重新創建以下代碼?談到異步時我很迷茫。Silverlight中的HttpWebRequest
public class StringGet
{
public static string GetPageAsString(Uri address)
{
string result = "";
// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Read the whole contents and return as a string
result = reader.ReadToEnd();
}
return result;
}
我不認爲WebClient的可替代的HttpWebRequest。您可以使用HttpWebRequest而不是WebClient,但不能用其他方式替換它。 – nubm