How to get all subsite from site collection with Elevated Privileges using SSOM


try
{
    SPSecurity.RunWithElevatedPrivileges(delegate ()
    {
        using (SPSite site = new SPSite("http://localhost/sites/collectioname/"))
        {
            foreach (SPWeb webCol in site.AllWebs)
            {
                if (!webCol.ServerRelativeUrl.Equals(string.Empty))
                    DropDownList1.Items.Add(webCol.ServerRelativeUrl);
            }

        }

    });
}
catch (Exception ex)
{

}

Comments

Popular posts from this blog

SharePoint Integration with IIS

How to Create an Auto-Incrementing Number Field in a SharePoint List

Error:Installing product D:\exchangeserver.msi failed. Fatal error during installation. Error code is 1603.