Esempio n. 1
0
        /// <summary>
        /// Returns the contents of the file specified in the migrated key - if it exists
        /// If the file doesn't exist, then just return the default value
        /// </summary>
        /// <param name="migratedKey"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        private string GetMigratedXSLT(string migratedKey, string defaultValue)
        {
            string result = defaultValue;

            try
            {
                string url = Utils.GetWebProperty(migratedKey, "", _web);

                if (!String.IsNullOrEmpty(url))
                {
                    url = Utils.GetAbsoluteURL(_web, url);
                    string     contents = string.Empty;
                    WebRequest request  = WebRequest.Create(url);
                    request.Credentials = CredentialCache.DefaultCredentials;
                    using (WebResponse response = request.GetResponse())
                    {
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            result = reader.ReadToEnd();
                        }
                        response.Close();
                    }
                }
            }
            catch
            {
            }

            return(result);
        }