Exemplo n.º 1
0
        public ValidateResult Validate(string url)
        {
            ValidateResult result = new ValidateResult();

            using (WebClient wc = new CFXWebClient())
            {
                RemoteCertificateValidationCallback callback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
                {
                    return true;
                };

                ServicePointManager.ServerCertificateValidationCallback += callback;
                try
                {
                    StreamReader Reader = new StreamReader(wc.OpenRead(url));
                    result.Tag = Reader.ReadLine();
                    result.UserID = Reader.ReadLine();
                    Reader.Close();
                }
                catch (Exception ex)
                {
                    logger.Info("SSOValidate>Validate  ", ex, tag);
                }
                ServicePointManager.ServerCertificateValidationCallback -= callback;
            }

            return result;
        }
Exemplo n.º 2
0
        public static String Post(string url, DataType dataType, string data, System.Net.WebProxy proxy = null, int timeOut = 2000)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url");
            }

            using (WebClient client = new CFXWebClient(timeOut))
            {
                client.Proxy = proxy;
                client.Headers.Add(HttpRequestHeader.Accept, ContetntTypeString(dataType));
                client.Headers.Add(HttpRequestHeader.ContentType, ContetntTypeString(dataType));
                client.Encoding = System.Text.Encoding.UTF8;
                return client.UploadString(url, "POST", data);
            }
        }