Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
just did an edit please check btw thanks for ur response –  Sree Kuttan Mar 14 '13 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 !) –  Francois Verbeeck Mar 14 '13 at 18:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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