Apply custom masterpage for a new site collection

1.1k Views Asked by At

This works for existing site collection and any new sites under it and their subsites BUT when I create a new site collection, well i can't even create a new site collection now as it gives me file not found error as the root site of my new sitecollection is unable to find the masterpage...WHY?? I mean how??

using (SPWeb currentWeb = (SPWeb)properties.Feature.Parent)
            {
                using (SPSite currentSite = currentWeb.Site)
                {
                   //Set Masterpage
                    Uri masterURI = new Uri(currentSite.Url + "/_catalogs/masterpage/V4Copy.master");
                    currentWeb.CustomMasterUrl = masterURI.AbsolutePath;
                    currentWeb.MasterUrl = masterURI.AbsolutePath;
                    currentWeb.Update();
                }
            }
0

There are 0 best solutions below