有人可以建议在SharePoint Web部件中提供下载文件的最佳方法吗?该文件将根据请求动态创建,但我仍然需要显示正在显示的标准页面以及正在下载的文件。

有帮助吗?

解决方案

最后,我在用户选择“导出”选项后,在重新加载期间动态地将iFrame添加到Web部件,并在其中加载了处理发送的标准.aspx页面。这解决了必须发送Response.End

的问题

其他提示

此示例的基本要素非常简单,可以在Microsoft文章中找到这里

Microsoft文章包含以下代码段:

private void Page_Load(object sender, System.EventArgs e)
{
  //Set the appropriate ContentType.
  Response.ContentType = "Application/pdf";
  //Get the physical path to the file.
  string FilePath = MapPath("acrobat.pdf");
  //Write the file directly to the HTTP content output stream.
  Response.WriteFile(FilePath);
  Response.End();
}

那应该对你有帮助。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top