System.Net.Browser.BrowserHttpWebRequestInternal.BeginGetResponse C# (CSharp) Method

BeginGetResponse() public method

public BeginGetResponse ( AsyncCallback callback, object state ) : IAsyncResult
callback AsyncCallback
state object
return IAsyncResult
		public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
		{
			// we're not allowed to reuse an aborted request
			if (aborted)
				throw new WebException ("Aborted", WebExceptionStatus.RequestCanceled);

			async_result = new HttpWebAsyncResult (callback, state);

			dispatcher.BeginInvoke (new Action (InitializeNativeRequestSafe), null);

			return async_result;
		}

Usage Example

        private IAsyncResult GetResponse(string method, Uri uri, bool sendHeaders)
        {
            if ((uri.Scheme != "http") && (uri.Scheme != "https"))
            {
                async_result.Exception = new SecurityException("Bad scheme");
                async_result.SetComplete();
                return(async_result);
            }

            // this is a same site (site of origin, SOO) request; or
            // we either already know the policy (previously downloaded); or
            // we try to download the policy
            if (!IsDownloadingPolicy())
            {
                policy = CrossDomainPolicyManager.GetCachedWebPolicy(uri);
                if (policy == null)
                {
                    // we'll download the policy *then* proceed to the requested URI
                    policy = CrossDomainPolicyManager.PolicyDownloadPolicy;

                    Uri silverlight_policy_uri         = CrossDomainPolicyManager.GetSilverlightPolicyUri(uri);
                    BrowserHttpWebRequestInternal preq = new BrowserHttpWebRequestInternal(null, silverlight_policy_uri);
                    return(preq.BeginGetResponse(new AsyncCallback(SilverlightPolicyCallback), preq));
                }
            }

            // Console.WriteLine ("{0} '{1}' using policy: {2}", method, uri, policy);
            HttpWebRequest wreq = GetHttpWebRequest(uri);

            wreq.Method = method;
            // store exception, to throw later, if we have no policy or are not allowed by the policy
#if !ANDROID_HACK
            if ((policy == null) || !policy.IsAllowed(wreq))
            {
                if ((policy == null) || (policy.Exception == null))
                {
                    async_result.Exception = new SecurityException();
                }
                else
                {
                    async_result.Exception = policy.Exception;
                }
                async_result.SetComplete();
                return(async_result);
            }
#endif

            if (!sendHeaders)
            {
                wreq.Headers.Clear();
            }
            wreq.progress = progress;

            return(wreq.BeginGetResponse(new AsyncCallback(EndCallback), wreq));
        }
All Usage Examples Of System.Net.Browser.BrowserHttpWebRequestInternal::BeginGetResponse