Ejemplo n.º 1
0
        public virtual bool CheckUrl(string url, ConsoleWrapper console)
        {
            Uri  websiteUri = null;
            bool result     = Uri.TryCreate(url, UriKind.Absolute, out websiteUri);

            if (result == false)
            {
                console.WriteLine("Error. Invalid Url. The format of the Url could not be determined.");
            }

            if (result == true && websiteUri.Scheme != Uri.UriSchemeHttps && websiteUri.Scheme != Uri.UriSchemeHttp)
            {
                console.WriteLine("Error. Invalid Url. The Url does not contain Http or Https scheme.");
                result = false;
            }

            return(result);
        }
        public virtual bool CheckRedirection(string url, ConsoleWrapper console)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method            = "HEAD";
            request.AllowAutoRedirect = false;
            bool result = true;

            try
            {
                using (var response = request.GetResponse() as HttpWebResponse)
                {
                }
            }
            catch
            {
                console.WriteLine("Error. The server is redirecting the request for this url.");
                result = false;
            }

            return(result);
        }