Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net SharePoint Web部件中的Response.WriteFile_Asp.net_Sharepoint_Web Parts - Fatal编程技术网

Asp.net SharePoint Web部件中的Response.WriteFile

Asp.net SharePoint Web部件中的Response.WriteFile,asp.net,sharepoint,web-parts,Asp.net,Sharepoint,Web Parts,我正在开发一个Web部件,其中我必须提供指向文件的链接。一个要求是,用户应该能够单击文件链接,并出现一个文件“另存为”对话框,允许用户将文件下载到PC 我尝试过使用Response.WriteFile,但它无法与SharePoint Web部件一起工作,因此现在我被卡住了。假设您的文件是动态生成的,而不是在库中,您可以在此处看到类似的帖子: 基本上,所描述的解决方案包括在web部件上添加到标准aspx页面的链接,并让该aspx页面处理文件下载(因为您不能使用Response.End in您的we

我正在开发一个Web部件,其中我必须提供指向文件的链接。一个要求是,用户应该能够单击文件链接,并出现一个文件“另存为”对话框,允许用户将文件下载到PC


我尝试过使用
Response.WriteFile
,但它无法与SharePoint Web部件一起工作,因此现在我被卡住了。

假设您的文件是动态生成的,而不是在库中,您可以在此处看到类似的帖子:


基本上,所描述的解决方案包括在web部件上添加到标准aspx页面的链接,并让该aspx页面处理文件下载(因为您不能使用Response.End in您的web部件)

当您在web部件中时,您需要直接引用HTTPContext而不是Response对象

i、 e..HTTPContext.Current.Response.Write(“某物”)