私はこのコードを持っています:
private HttpWebRequest request;
private HttpWebResponse wResponse;
private CookieContainer cookieContainer = new CookieContainer();
#region PRIVATE METHODS
private void RunRequest(string url)
{
request = HttpWebRequest.Create(new Uri(url)) as HttpWebRequest;
request.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16";
request.ContentType = "application/x-www-form-urlencoded";
request.CookieContainer = cookieContainer;
request.Method = "GET";
StartWebRequest(request);
//Do smthng
while (wResponse == null) { }
}
private void StartWebRequest(HttpWebRequest request)
{
request.BeginGetResponse(FinishWebRequest, request);
}
private void FinishWebRequest(IAsyncResult result)
{
wResponse = (result.AsyncState as HttpWebRequest).EndGetResponse(result) as HttpWebResponse;
}
#endregion
また、wRequest 変数には応答が入力されていません。AsyncState で私はこれを持っています:
何が問題なのですか?
psデスクトップアプリでも同じコードがうまく機能します。
ありがとう、パベル。