Example #1
0
        public ActionResult SetFiletypes(List <string> filetypes)
        {
            try
            {
                string cdnFileTypes;

                using (var clientContext = GetClientContext())
                {
                    var tenant = new Office365Tenant(clientContext);

                    var newFileTypes = string.Join(",", filetypes);

                    tenant.SetTenantCdnPolicy(SPOTenantCdnType.Public, SPOTenantCdnPolicyType.IncludeFileExtensions, newFileTypes);

                    var publicCDNPolicies = tenant.GetTenantCdnPolicies(SPOTenantCdnType.Public);

                    clientContext.ExecuteQuery();

                    cdnFileTypes = publicCDNPolicies.Where(s => s.StartsWith(SPOTenantCdnPolicyType.IncludeFileExtensions.ToString())).First();
                }

                return(Json(ConvertToList(cdnFileTypes)));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                return(Json(ex.Message));
            }
        }