string siteUrl = "https://contoso.sharepoint.com/sites/mytestsite";
string targetSiteUrl = "https://contoso.sharepoint.com/sites/mytargetsite";
string userName = "[email protected]";
AuthenticationManager am = new AuthenticationManager();
using (var cc = am.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, GetSecureString("Password")))
    using (var ccTarget = cc.Clone(targetSiteUrl))
      var pageTransformator = new PageTransformator(cc, ccTarget);
      var pages = cc.Web.GetPages();
      foreach (var page in pages)
          PageTransformationInformation pti = new PageTransformationInformation(page)
              // If target page exists, then overwrite it
              Overwrite = true,

              Console.WriteLine($"Transforming page {page.FieldValues["FileLeafRef"]}");
          catch(ArgumentException ex)
              Console.WriteLine($"Page {page.FieldValues["FileLeafRef"]} could not be transformed: {ex.Message}");

the above code is provided by microsoft to transform classic pages to modern UI but it is defaulted to allow only pages library.

Can anyone suggest if there are any other options to handle custom site pages or pages from other libraries.

reference to the microsoft documentation : Classic to modern UI transformation via .Net solution

1 Answer 1


From what I know there is no path for upgrade, you need to recreate the pages migrate content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.