2016-09-17 121 views
0

我有几个有关SharePoint网站和C#集成的问题。 我有一个SharePoint网站&我可以添加文件,视频到这个网站。 我有这个网站的具体的UI设计。但实际上我不能添加我的UI设计里面这个SharePoint网站(我不知道这个。我是新来的SharePoint。) 因为我决定采取以下脚步。Sharepoint获取所有列表数据c#

  1. 创建Asp.Net MVC网站并添加我的UI设计在该网站内。
  2. 从asp.net MVC网站访问我的SharePoint网站。

在我的第2步我的过程应该是这样..

2.1里面的一些搜索框,用户可以搜索 但在这里所有的数据应该来自SharePoint数据(文件名,视频的名字,我已添加)这些文件的名称应该加载到搜索框,如谷歌搜索。

2.2当用户选择1个文件名并按搜索按钮时,他应该导航到SharePoint网站。

我的SharePoint网站现在完成。我可以添加视频搜索使用名称的那些东西,可以做。但这个搜索部分我需要从我的asp.net MVC网站做​​。

那么我应该怎么做?

我看到SharePoint使用休息api.but我找不到好的资源。 大多数SharePoint教程都来自Visual Studio - SharePoint - SharePoint解决方案项目。

但我需要在我的Asp.Net MVC应用程序中执行此操作。

我试图做这样的 How to: Retrieve Lists

,但它不是成功&我使用的SharePoint 2013网络版


编辑

本规范我tried.but不sucess.right现在我试图将数据检索到我的标签或文本框。

using SP = Microsoft.SharePoint.Client; 

string siteUrl = "http://SMit.sharepoint.com/MySiteName"; 

SP.ClientContext clientContext = new SP.ClientContext(siteUrl); 
SP.Web oWebsite = clientContext.Web; 
SP.ListCollection collList = oWebsite.Lists; 

clientContext.Load(collList); 

clientContext.ExecuteQuery(); 

foreach (SP.List oList in collList) 
{ 
    label1.Text = label1.Text + ", " + oList.Title +""+ oList.Created.ToString(); 
    //Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString()); 
} 

继方法还我试图

string siteUrl = "http://SMit.sharepoint.com/MySiteName"; 

    using (SP.ClientContext spcontext = new SP.ClientContext(siteUrl)) 
       { 
        spcontext.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication; 
        spcontext.FormsAuthenticationLoginInfo = new SP.FormsAuthenticationLoginInfo("[email protected]", "password"); 
        spcontext.Load(spcontext.Web, w => w.Title, w => w.ServerRelativeUrl, w => w.Lists); 
        spcontext.ExecuteQuery(); 
        //Console.WriteLine(spcontext.Web.ServerRelativeUrl); 
//I haven done anything here.i want to check spcontext.ExecuteQuery(); works or //not. 
       } 

,但现在我得到以下类似的错误。 错误发生在 spcontext.ExecuteQuery();

Microsoft.SharePoint.Client.Runtime.dll中发生未处理的类型为“Microsoft.SharePoint.Client.ServerException”的异常 其他信息:用户的登录名或密码无效。

+1

你应该发布你已经使用过的代码,以什么方式不起作用。否则没有人会知道为什么它不工作 – Bassie

+0

我没有更新我的问题,但我已经添加了该网址。但那一个是基本的。我想我也应该给认证。 – TDM

+0

你有没有得到任何错误? – Bassie

回答

0

var securePassword = new SecureString();

foreach(char in“Password”) { securePassword.AppendChar(c); } spContext.Credentials = new SharePointOnlineCredentials(“[email protected]”,securePassword);

+0

这一个不工作 – TDM

+0

你使用url来生成spContext对象吗? 对不起,延迟回复。 –

相关问题