0

I have created a sandbox solution in which there is one feature for creating two sub-sites. In the event receiver of that feature I have created two sites programmatically.

The code is as per below:

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    try
    {
        SPWeb currentWeb = properties.Feature.Parent as SPWeb;


        currentWeb.Webs.Add("Blog", "Blogs", "", (uint)1033, "BLOG#0", false, false);
        currentWeb.Webs.Add("COMMUNITY", "Community", "", (uint)1033, "COMMUNITY#0", false, false);

    }
    catch (Exception ex)
    {

    }
    finally
    { }  

The feature is placed in the web template, under <WebFeatures>. But after creating site from the web template sometimes sub sites are created and sometimes not created.

What am I missing?

0

You have to enable social feature at the site collection level in order to create a community subsite.

0

Use parent as SPSite

SPSite site = properties.Feature.Parent as SPSite;
using (SPWeb currentWeb = site.RootWeb)
{ }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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