示例#1
0
        internal void UpdateServersCache(string key, RawResponse rawResponse, string pathUrl, string currentSiteUrl)
        {
            foreach (string server in _servers)
            {
#pragma warning disable 612,618
                ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
#pragma warning restore 612,618

                NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty);
                queryString["CacheLevel"]     = "First";
                queryString["key"]            = key;
                queryString["pathUrl"]        = pathUrl;
                queryString["currentSiteUrl"] = currentSiteUrl;

                queryString.ToString();

                var httpHandlerUrlBuilder = new UriBuilder(server + "_layouts/OceanikCacheSync.ashx")
                {
                    Query = queryString.ToString()
                };

                var req = (HttpWebRequest)WebRequest.Create(httpHandlerUrlBuilder.Uri);
                req.Method      = "POST";
                req.Credentials = CredentialCache.DefaultCredentials;

                byte[] rawResponseBytes = SerializeObject <RawResponse> .Object2ByteArray(rawResponse);

                req.ContentLength = rawResponseBytes.Length;
                req.ContentType   = "text/xml";

                Stream requestStream = req.GetRequestStream();
                requestStream.Write(rawResponseBytes, 0, rawResponseBytes.Length);
                requestStream.Close();
                req.GetResponse();
            }
        }