Tuesday, 18 August 2015

App Web and Host Web

App web

The special website to which the app is deployed is called an app web.. Although the app web has its own isolated domain, it is in the same site collection as the host web.
SharePoint components are deployed to a special website with its own domain. This is called the app web.


Host Web

The Host Web is nothing but the SharePoint site where the App is actually installed.
In Short:
App Web - Site on which the App is deployed
Host Web - Site on which the App is installed

URL

HostWeb url - https://xyzonline.sharepoint.com/sites/OrgIntranet/sap



We can create our custom SharePoint artefacts like list,content types as part of our Auto Hosted or Provider hosted apps too and not only in SharePoint Hosted apps.

Your feature and list will be deployed in the AppWeb which is a subsite that gets created whenever a new app is created. So instead of checking for the list and the feature in the host web, You can see them as part of the AppWeb.

You can find the AppWeb's url from Site Settings->Site Collection Administration section->Site hierarchy, Title will be your App name.

Once you know the url, You can visit the manage features page of the App Web through "URL_of_app_web/_layouts/15/ManageFeatures.aspx". Here you can see your feature already activated if it has been properly deployed.

And to see your list visit "URL_of_app_web/lists/list_internal_name". Here you can see your list along with his items.

If I manually (i.e. SP OOTB ) created a List within site (i.e. under HostWeb - https://xyzonline.sharepoint.com/sites/OrgIntranet/sap ) and if I wanted to get this list so will go with below code

    //list created by Sharepoint OOTB - HostWeb
    var context = new SP.ClientContext(appWebUrl);
    var appCtxSite = new SP.AppContextSite(context, hostWebUrl);
    var web = appCtxSite.get_web();
    var list = web.get_lists().getByTitle("MySAPLst");
    context.load(list);

If I created a list using visual studio so the list will be reside under App Web i.e. https://xyzonline-48f6dcc328fa2.sharepoint.com/sites/OrgIntranet/sap/SharePointApp1 and if you wanted to get this list so will go with below code

//Get List created by Visual Studio - AppWeb

var context = new SP.ClientContext(appWebUrl);
var web = context.get_web();
var list = web.get_lists().getByTitle("TestList");
context.load(list);
 
   OR

//Get List created by Visual Studio
var context = new SP.ClientContext.get_current();
var web = context.get_web();
list = web.get_lists().getByTitle('TestList');
context.load(list);



No comments:

Post a Comment