【发布时间】:2012-06-13 10:37:40
【问题描述】:
我正在尝试从驻留在 Intranet 上的页面中获取数据。 Intranet 基于 SharePoint。地址如下所示:http://collab.intranet.com/Pages/Default.aspx。
我正在使用 HTML Agility Pack (.NET) 来获取数据,我已经在外部网页而不是 Intranet 上处理了这些数据。我可以通过浏览器访问内网页面。
编辑:所以问题是:如何授予对需要访问 SharePoint Intranet 页面的程序的访问权限?
我用来检索数据的代码(C#):
String webpage = "http://collab.intranet.com/Pages/Default.aspx";
String mainTarget = "table";
String mainAttribute = "id";
String mainId = "activeProjects";
var webGet = new HtmlWeb();
var document = webGet.Load(webpage);
var partOfWebpage = from completeWebpage in document.DocumentNode.Descendants(mainTarget)
where
completeWebpage.Attributes[mainAttribute] != null &&
completeWebpage.Attributes[mainAttribute].Value == mainId &&
completeWebpage.Attributes[mainAttribute].Value != null
select completeWebpage.InnerHtml;
【问题讨论】:
-
我打赌缺少身份验证。您可以使用 WebClient.Download 方法获取内容吗?发生错误时的http状态是什么?
-
史蒂夫 B,我相信你是对的。我用WebClient方法试了一下,收到“远程服务器返回错误:(401) Unauthorized”。我可以做些什么来授权 C# 会话?我已经添加了我正在使用的代码。
-
另外,我认为内网是基于SharePoint的。是否可以授予exe文件权限?
标签: c# .net sharepoint html-agility-pack intranet