我正在使用自定义WebPart,为此我需要应用程序页面来呈现PDF文件。显示PDF - 应用程序页面SharePoint
我目前使用以下链接http://support.microsoft.com/kb/306654
它工作正常,在ASP.NET,但在SharePoint中给出了一个空白页。
下面的代码: (PDF文件在同一目录)
Response.ClearContent();
Response.ClearHeaders();
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Get the physical path to the file.
string FilePath = MapPath("Test.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.Flush();
Response.End();
工作于它的最后几个小时,让我疯了...任何想法?
问题可能是这一行:string FilePath = MapPath(“Test.pdf”); 。你确定文件存在吗(当在sharepoint下运行时)? – 2010-05-26 01:45:41
@Raj:这不是问题。文件在同一个文件夹中。另外,如果我使用Byte数组编写PDF,它在ASP.NET中工作,我面临同样的问题。 – spt3210 2010-05-26 13:05:51
我意识到它可以在ASP.NET中使用,但是您的Web部件甚至在Sharepoint中执行?删除Web部件中的所有代码并放入Response.Write(“hello”)。该行是否执行? – 2010-05-26 16:08:09