将SitePages部署到主机Web(P-HA) [英] Deploy SitePages to Host Web (P-HA)

查看:72
本文介绍了将SitePages部署到主机Web(P-HA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






我正在研究sharepoint提供商托管的解决方案,并从农场解决方案中获得~80个SitePages希望通过新的应用模型部署。 
$


我知道在我想要部署功能时,会在App Web部件上配置此类工件他们到主机网站。 
$


我现在的问题:
$


是否可以部署这些页面或者从准备好的提供商托管应用程序(应用程序部分)到主机网站,而不是默认制作的应用程序网站? 
$




提前致谢。



CaMeL

解决方案

您好,


在提供商托管应用程序中,您可以使用客户端对象模型将网站页面上传到主机Web库:

私有字符串UploadFile(字符串sourceFileURL,字符串targeFolder,字符串targetName,ClientContext c lientContext)
{
string serverRelativeURL = string.Empty;

//从应用服务器中的本地文件打开文件
var streamMaster = this.OpenFile(sourceFileURL);
fcimaster = new FileCreationInformation();
fcimaster.ContentStream = streamMaster;
fcimaster.Url = targetName;
fcimaster.Overwrite = true;

//将文件添加到目标文件夹(在我们的例子中,母版页库中的自定义文件夹)
Microsoft.SharePoint.Client.File newFile = clientContext.Web.GetFolderByServerRelativeUrl(targeFolder) .Files.Add(fcimaster);
clientContext.Load(newFile,Newfile => Newfile.ServerRelativeUrl);
clientContext.ExecuteQuery();
serverRelativeURL = newFile.ServerRelativeUrl;

//返回上传文件的URL
return serverRelativeURL;
}

如何使用SharePoint 2013应用程序配置文件


谢谢


最好的问候


Hi,

I am working on the sharepoint provider-hosted solution and have ~80 SitePages from farm solution that would like to deploy via new app model. 

I know that provisioning of such artifacts will be made to App Web part after feature's activation while I want to deploy them to Host Web. 

My question now:

Is it possible to deploy such pages or new one from prepared Provider-Hosted App (App part) to Host Web site and not to App Web as it is made by default? 


Thanks in advance.

CaMeL

解决方案

Hi,

In the Provider Hosted App, you could upload the site pages to the host web library using Client Object Model:

   private string UploadFile(string sourceFileURL, string targeFolder, string targetName, ClientContext clientContext)
        {
            string serverRelativeURL= string.Empty;

            //open the file from local file in the app server
            var streamMaster = this.OpenFile(sourceFileURL);
            fcimaster = new FileCreationInformation();
            fcimaster.ContentStream = streamMaster;
            fcimaster.Url = targetName;
            fcimaster.Overwrite = true;

            //add the file to the target folder (in our case, custom folder inside Master Page Library)
            Microsoft.SharePoint.Client.File newFile = clientContext.Web.GetFolderByServerRelativeUrl(targeFolder).Files.Add(fcimaster);
            clientContext.Load(newFile, Newfile => Newfile.ServerRelativeUrl);
            clientContext.ExecuteQuery();
            serverRelativeURL = newFile.ServerRelativeUrl;

            //return the URL of uploaded file
            return serverRelativeURL;
        }

How to provision files using SharePoint 2013 app

Thanks

Best Regards


这篇关于将SitePages部署到主机Web(P-HA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆