Ejemplo n.º 1
0
        /// <summary>
        /// Send a HTTP GET request to the URI
        /// </summary>
        /// <param name="uri">The URI for the request</param>
        /// <returns>Returns a task wrapping a BrowserResponse</returns>
        public static async Task <BrowserResponse> Get(string uri)
        {
            // perform some validation on url here
            if (!uri.StartsWith("http://www.") | !uri.StartsWith("https://www."))
            {
                // fix uri string
            }
            //try
            //{
            HttpResponseMessage httpres = await client.GetAsync(uri);

            return(await BrowserResponse.CreateAsync(httpres));

            //} catch (InvalidOperationException e)
            //{
            //    MessageBox.Show("Invalid URI provided");
            //}

            throw new ArgumentException("Attempted to navigate using improper URI Argument");
        }