1
我嘗試使用MVC從SharePoint文檔庫下載文檔,但是每當我嘗試運行我的代碼時,都會收到上述錯誤。我對SharePoint很陌生,所以請好起來。這裏是我的代碼:指定的參數超出有效值的範圍。參數名稱:服務器相對URL
網絡幫手:
public Stream DownloadDocument(string SiteURL, string documentName)
{
ListItem item = GetDocumentFromSP(documentName);
if (item != null) {
using (ClientContext clientContext = new ClientContext(SiteUrl)) {
FileInformation fileInformation =
Microsoft.SharePoint.Client.File.OpenBinaryDirect(
clientContext,
item["My Document.docx"].ToString()
);
return fileInformation.Stream;
}
}
return null;
}
控制器:
public ActionResult Index()
{
Stream documentDownload =
WebHelper.DownloadDocument(
"http://MySharePointServer/Docs/Forms/AllItems.aspx",
"My Document"
);
model.downloadedDoc = documentDownload;
return view(model)
}
這個工作。不能相信我無法爲自己解決這個問題 –
有時你可以盯着某些東西,而不是通過樹木看到森林! –