MVC を使用して SharePoint ドキュメント ライブラリからドキュメントをダウンロードしようとしていますが、コードを実行しようとすると、上記のエラーが発生します。SharePoint は初めてなので、よろしくお願いします。ここに私のコードがあります:
Web ヘルパー:
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)
}