我将以下 URL 用于OAuth2.0
并将其传递给 Post()。
结果:我的应用程序没有运行并等待资源。我想可能它没有得到 HTTP 响应。
请验证并让我知道我在这里做错了什么?
private void Post(string address)
{
System.Uri targetUri = new System.Uri(address);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(targetUri);
request.Method = "POST";
request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
}
// STEP4 STEP4 STEP4
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);
string results;
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
results = httpwebStreamReader.ReadToEnd();
//TextBlockResults.Text = results; //-- on another thread!
SkyDriveContent test = new SkyDriveContent();
test.Name = results;
str_results = results;
Dispatcher.BeginInvoke(() => ContentList.Add(test));
}
myResponse.Close();
}