SharePoint 2013 Hosting :: How to Create Site Creation App in SharePoint 2013

Today we will learn step by step how to create site creation app in SharePoint 2013.

ahp banner sharepoint-01

In SharePoint Server 2013, a Site Creation App allows an option to the users to create a site even if the user has no permission to create a site from a web template that we can configure either custom or OOTB. For example, if we use SharePoint as a social platform and use community sites and community portalm then we can provide an option to user this app where the user can create a community site (site template will be configured in app code).

Prerequisites for setting up your development environment to work with a Site Creation App

To create the SharePoint Hosted App that uses the JavaScript object model to work with a Site Create App, you’ll need:

  • Visual Studio 2012
  • App Configuration in server
  • Local administrator permissions for the logged-on user

Create a farm solution and SharePoint-Hosted App

Use the following procedure to create a farm solution and SharePoint-Hosted App in Visual Studio 2012:

  • Run Visual Studio as administrator, and choose “File” -> “New” -> “Project…”.
  • In the New Project dialog box, choose “.NET Framework 4.5″ from the drop-down list at the top of the dialog box.
  • In the Templates list, expand “Office/SharePoint”, choose “Apps”, and then choose the “App for SharePoint 2013″ template.
  • Name the project “SiteApp”, and then choose the “OK” button.
  • In the SharePoint Customization Wizard dialog box, choose “Deploy as a farm solution” and then choose the “Finish” button.
  • In Solution Explorer, open the shortcut menu for the SiteApp project, and expand the Pages folder and click on the default.aspx page.
  • In the markup of the “Default.aspx” file, paste the following code between the “Main” asp:Content tags. This code defines controls and script references.


Site Name: <inputtype=”text”id=”siteName”value=””/>

  • Open the “App.js” file under the Script folder. Replace with the following code:

function getQueryStringValue(key) {
    var returnValue = “”;
    var params = document.URL.split(“?”)[1].split(“&”);
    var strParams = “”;
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split(“=”);
        if (singleParam[0] === key) {
            return decodeURIComponent(singleParam[1]);

    return returnValue;
function createSite() {

    var hostWebUrl = getQueryStringValue(“SPHostUrl”);
    spcontext = new SP.ClientContext.get_current();
    //then use the host web URL to get a parent context -this allows us to get data from the parent
    parentCtx = new SP.AppContextSite(spcontext, hostWebUrl);
    currentWeb = parentCtx.get_web();

    context.executeQueryAsync(onCreationSuccess, OnFailure);

function onCreationSuccess() {
    //alert(“In onCreationSuccess”);
    var appInstanceID = currentWeb.get_appInstanceId();
    var webCreateInfo = new SP.WebCreationInformation();
    webCreateInfo.set_description(“This site created from Javascript”);
    var site = $(“#siteName”).val();

    webCreateInfo.set_webTemplate(“COMMUNITY#0″);// you can add webtemplate as per your choice
    web = currentWeb.get_webs().add(webCreateInfo, false, appInstanceID);

    context.executeQueryAsync(onSuccess, OnFailure);


function onSuccess() {
    alert(“Web created”);
function OnFailure(sender, args) {

  • Open the “AppManifest.xml” file and set the permission to “Site Collection as Full Control”
  • To test the solution, on the menu bar, choose “Deploy”.

I hope you like my article .. Happy coding :)

Best Recommended SharePoint 2013 Hosting is Perfect, suitable hosting plan for a starter in SharePoint. ASPHostPortal  the leading provider of Windows hosting and affordable SharePoint Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability