iFrame没有看到pdf文档 [英] iFrame not seeing pdf document
问题描述
您好,
我正在尝试从后面的代码中将pdf文档加载到iFrame中。我在页面加载后面的代码中使用以下代码:
Hello,
I am trying to load a pdf document into an iFrame from code behind. I am using the following code in code behind on Page Load:
if (Session["Document"].ToString() != string.Empty)
{
string document = Session["Document"].ToString();
pdfIframe.Attributes.Add("src", document);
}
当我使用内部网络服务器从Visual Studio 10内部运行它时它完美运行,但它确实有效当它上传到网站时它根本不起作用(它会抛出错误页面)其他所有内容(例如:数据库,查询等)都可以正常工作。
任何帮助表示赞赏。
我的尝试:
我已经完成了Google搜索并尝试了一些不同的代码变体。我将web.config文件更改为早期版本。我试图在Firefox和IE中运行它。没有运气。
It works perfectly when I run it from inside Visual Studio 10 using the internal web-server, but it does not work at all when it is uploaded to the website (it throws an error page) Everything else (eg: database, queries, etc.) works fine.
Any help appreciated.
What I have tried:
I have done a Google search and tried a few different code variations. I changed the web.config file to an earlier version. I have tried to run it in Firefox and IE. No luck.
推荐答案
跟进;虽然我仍然试图读取页面错误(到目前为止不成功),但我想切换到Google Docs阅读器以查看错误是否可能与Adobe阅读器有关(并非罕见)。同样,它在VS 2010环境中完美运行,但它仍然会引发某种运行时错误,因为它现在指的是我放入web.config文件的错误页面。我将在下面显示新代码,买我不认为这是一个编码问题(这来自显然无法解决它的人!)。我觉得它与web.config文件有关(如果你愿意,只是预感)。请继续,当我继续试图获得错误读数时,有人必须先看到这样的问题。任何想法都是受欢迎的。谢谢,帕特。
Following Up; although I am still trying to get a read out of the page error (unsuccessful so far), I thought of switching to a Google Docs reader to see if the error might be with the Adobe reader (not uncommon). Again, it works perfectly in the VS 2010 environment, but it still throws a runtime error of some kind since it is now referring to an error page that I have put in to the web.config file. I'll show the new code below, buy I do not think it is a coding problem (this coming from someone that obviously cannot fix it!). I feel it has something to do with the web.config file (just a hunch if you will). PLEASE, as I continue to try to get an error readout, someone MUST have seen an issue like this before. Any idea's are welcome. Thank you, Pat.
//Using iFrame with Google Docs
if (Session["Document"].ToString() != string.Empty)
{
string document = Session["Document"].ToString();
string pdfPage = "http://docs.google.com/gview?url=" + document + "&embedded=true";
pdfFrame.Attributes.Add("src", pdfPage);
}
else
{
ClientScriptManager script = Page.ClientScript;
if (!script.IsClientScriptBlockRegistered(this.GetType(), "Alert"))
{
script.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Sorry, this document cannot be found. ')", true);
return;
}
}
这篇关于iFrame没有看到pdf文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!