0

I am trying to create a feature which creates a site collection using a custom/ootb template in a specified application pool. My question is is this possible if yes then how

what i'm trying to do is i have a site created on Office 365 which is made on sandboxed solution which has web parts too. the thing is i want to create a feature which i will install on central admin and as soon as i activate it, it creates a new site collection or a site an add a user group an various other things like list creation etc. which is present on the O365 site. now it do not have to be using save site as template option...

any help will be appreciated Thanks

1 Answer 1

2

You could write an event receiver when your feature is activated and run the process under the SharePoint Farm account (running under elevated privileges will only work if your application pool account has too much right...).

Usually, one ore more SPWeb would be created if needed through a feature (receiver) since it's under the context of an existing site collection but another site collection is definitively strange since you have to leave your current context.

What about a Central Administration feature instead ? It will still create your site collection (and your feature will thus be activated, meaning that you won't be able to create another one afterwards unless by deactivating and reactiving if you give add a timestamp in your url to have different site collection).

Some clarification about what you're trying to achieve might help the community to provide you a better answer / alternative.

2
  • just did an edit please check btw thanks for ur response Mar 14, 2013 at 17:45
  • you have to be careful & understand the difference between a site collection (SPSite) and a "site" (SPWeb). You can create subsite in a sandbox solution while you won't be able to create another site collection (even on a farm solution that would be hard). In your sandbox solution, you could do something like SPContext.Current.Web.Webs.Add(projectName, projectName, "Project site for " + projectName, (uint) currentWeb.Locale.LCID, Microsoft.SharePoint.SPWebTemplate.WebTemplateSTS, true, false) to create a new child web / site (and not a site collection !) Mar 14, 2013 at 18:01

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.