本文整理汇总了C#中System.Net.HttpWebRequest.BeginGetRequestStream方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWebRequest.BeginGetRequestStream方法的具体用法?C# HttpWebRequest.BeginGetRequestStream怎么用?C# HttpWebRequest.BeginGetRequestStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.HttpWebRequest
的用法示例。
在下文中一共展示了HttpWebRequest.BeginGetRequestStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostRegisterInfoAsync
public void PostRegisterInfoAsync(RegisterInfo registerInfo)
{
_requestState = new RequestState();
_registerInfo = registerInfo;
_httpWebRequest = (HttpWebRequest)WebRequest.Create(_registerURL);
_timer.Start();
_requestState.request = _httpWebRequest;
_httpWebRequest.Method = "POST";
_httpWebRequest.ContentType = "application/x-www-form-urlencoded";
_httpWebRequest.BeginGetRequestStream(new AsyncCallback(RequestCallback), _httpWebRequest);
}
示例2: GetRequestStreamAsynch
private Stream GetRequestStreamAsynch(HttpWebRequest request)
{
return AsynchHelper.WaitForAsynchResponse(
c => request.BeginGetRequestStream(c, null),
(r, s) => request.EndGetRequestStream(r)
);
}
示例3: Submit
public void Submit()
{
// Prepare web request...
webRequest = WebRequest.CreateHttp(url);
webRequest.Method = "POST";
webRequest.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);
webRequest.BeginGetRequestStream(new AsyncCallback(RequestReady), webRequest);
}
示例4: BeginRequest
private void BeginRequest(string method, HttpWebRequest httpRequest, AsyncRequest rawRequestData)
{
if (method == "PUT" || method == "POST")
{
httpRequest.BeginGetRequestStream(WriteStream, rawRequestData);
}
else
{
httpRequest.BeginGetResponse(ReadCallback, rawRequestData);
}
}
示例5: POST
protected void POST(string URL, string post_message)
{
POST_REQUEST = (HttpWebRequest)HttpWebRequest.Create(URL);
POST_REQUEST.Method = "POST";
POST_REQUEST.ContentType = "application/x-www-form-urlencoded";
POST_REQUEST.BeginGetRequestStream(result =>
{
Stream post_stream = POST_REQUEST.EndGetRequestStream(result);
byte[] ba = Encoding.UTF8.GetBytes(post_message);
post_stream.Write(ba, 0, ba.Length);
post_stream.Close();
POST_REQUEST.BeginGetResponse(new AsyncCallback(POST_Method_CallBack),POST_REQUEST);
}, POST_REQUEST);
}
示例6: WebRequestResult
public WebRequestResult(HttpWebRequest pRequest, ProxyTranslation pTranslation, AsyncCallback pCallback, HttpContext pContext, object pState)
{
context = pContext;
_request = pRequest;
_callback = pCallback;
translation = pTranslation;
IsCompleted = false;
AsyncState = pState;
if (_request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
_request.BeginGetRequestStream(new AsyncCallback(AsyncReturnStream), this);
else
_request.BeginGetResponse(new AsyncCallback(AsyncReturn), this);
}
示例7: GetWebRequest
protected override WebRequest GetWebRequest(Uri address) {
string a = address.ToString();
string[] words = a.Split(new Char[] { '?' });
_webRequest = (HttpWebRequest)System.Net.WebRequest.Create(new Uri(words[0], UriKind.RelativeOrAbsolute));
_webRequest.CookieContainer = App.CookieContainer;
_webRequest.Headers["Cache-Control"] = "no-cache";
_webRequest.Headers["User-Agent"] = Global.GetDeviceOSVersion();
_webRequest.Method = "POST";
_webRequest.Headers["token"] = this._token;
_webRequest.ContentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
_postId = words[1];
_webRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), _webRequest);
System.Threading.Thread.Sleep(1000);
return _webRequest;
}
示例8: run
public void run()
{
_asyncState = new ManualResetEvent(false);
// create a new request
_request = (HttpWebRequest) WebRequest.Create(_url);
_request.Method = "POST";
_request.Accept = "application/json";
_request.ContentType = _contentType;
if (_request.Method == "POST")
// Start the asynchronous operation to get the request-content
_request.BeginGetRequestStream(new AsyncCallback(getRequestCallback), _request);
else
// Start the asynchronous operation to get the response
_request.BeginGetResponse(new AsyncCallback(getResponseCallback), _request);
}
示例9: Run
public void Run()
{
try
{
string postString = string.Format("assertion={0}&audience={1}", HttpUtility.UrlEncode(Assertion), HttpUtility.UrlEncode(Audience));
PostBytes = Encoding.ASCII.GetBytes(postString);
Request = (HttpWebRequest)HttpWebRequest.Create("https://verifier.login.persona.org/verify");
Request.UserAgent = "Persona Client";
Request.Method = "POST";
Request.ContentType = "application/x-www-form-urlencoded";
Request.ContentLength = PostBytes.Length;
Request.BeginGetRequestStream(new AsyncCallback(OnGetRequestStream), null);
}
catch (Exception exception)
{
HandleException(exception);
}
}
示例10: GetRequestStreamAsync
public static Task<Stream> GetRequestStreamAsync(HttpWebRequest request)
{
var taskComplete = new TaskCompletionSource<Stream>();
request.BeginGetRequestStream(asyncResponse =>
{
try
{
HttpWebRequest responseRequest = (HttpWebRequest)asyncResponse.AsyncState;
Stream someResponse = (Stream)responseRequest.EndGetRequestStream(asyncResponse);
taskComplete.TrySetResult(someResponse);
}
catch (Exception)
{
taskComplete.TrySetResult(null);
}
}, request);
return taskComplete.Task;
}
示例11: HtttpPost
private void HtttpPost()
{
try
{
request = (HttpWebRequest)HttpWebRequest.Create("http://dldir1.qq.com/qqfile/qq/QQ2013/2013Beta5/6970/QQ2013Beta5.exe");
//Thread.Sleep(1000);
request.Method = "POST";
request.BeginGetRequestStream(ResponseStreamCallbackPost, request);
//request.BeginGetResponse(ResponseCallbackPost, request);
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.Timeout)
{
}
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Message + " Status:" + e.Status));
}
}
示例12: DoPost
protected void DoPost(string url, string post, Action<string> doOnFinish)
{
try
{
myRequest = HttpWebRequest.CreateHttp(url);
myRequest.Accept = "application/json";
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.CookieContainer = cookieContainer;
var async1 = myRequest.BeginGetRequestStream((result1) =>
{
HandleEndGetRequestStream(post, doOnFinish, result1);
},
null);
}
catch (Exception exc)
{
ShowErrorMessage(exc);
}
}
示例13: DownloadStringAsyncWithPost
public void DownloadStringAsyncWithPost(HttpWebRequest request, byte[] postData, string contentType)
{
_webRequest = request;
_webRequest.Method = "POST";
_webRequest.ContentType = contentType;
_webRequest.AllowReadStreamBuffering = true;
try
{
_webRequest.BeginGetRequestStream(BeginRequest, postData);
}
catch (SystemException)
{
// Bad news bears.
}
#if DEBUG && TRACKING_TIME
StartTimeTracking();
#endif
}
示例14: PhoneApplicationPage_Loaded
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
//myRequest = (HttpWebRequest)WebRequest.Create("http://passport.cnblogs.com/login.aspx");
if (NavigationContext.QueryString.Count > 0) {
username = NavigationContext.QueryString["username"];
password = NavigationContext.QueryString["password"];
}
myRequest = (HttpWebRequest)WebRequest.Create("http://m.cnblogs.com/mobileLoginPost.aspx");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
if (cookieContainer==null)
{
myRequest.CookieContainer = new CookieContainer();
}
myRequest.CookieContainer = cookieContainer;
myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
getFlashMemoryList();
}
示例15: PostImage
/// <summary>
/// Post image
/// </summary>
/// <param name="url"></param>
/// <param name="data"></param>
/// <param name="imgRaw"></param>
public void PostImage(
string url,
Dictionary<string, object> data,
WebPostImageObject media)
{
byte[] postData = BuildImagePostData(data, media);
try
{
Request = HttpWebRequest.Create(url) as HttpWebRequest;
Request.ContentType =
string.Concat("multipart/form-data; boundary=",
BOUNDARY);
Request.Method = "POST";
Request.BeginGetRequestStream(
(asyncResult) => OnGetRequestStreamCallback(asyncResult, postData),
Request);
}
catch (System.Exception e)
{
FirePostFailedEvent(e);
CleanUp();
}
}