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

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

SharePoint Integration with IIS

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