我正在使用自定義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