简体   繁体   中英

PDF file showing in iframe on localhost but now showing in web page online in asp.net

I am trying to show two different pdf files in two iframes in same webpage side by side. These pdf files are on web server. I can view these files in iframes during local run on localhost. But when i upload my application online, these PDF files are not visible in iframes.

Two panels with iframes in one div.

    <div>
        <asp:Panel runat="server" ID="pnlPDF_BKS" Style="height: 90%; width: 48%; float: left; margin-left: 3px; margin-top: 3px;">
            <iframe id="ifmPDF_BKS" runat="server" style="height: 90%; width: 48%; position: absolute; margin-top: 1px; margin-left: 1%; border-style: solid; border-color: #ace1d8; min-width: 600px;"></iframe>
        </asp:Panel>
        <asp:Panel runat="server" ID="pnlPDF_HIN" Style="height: 90%; width: 48%; float: right; margin-right: 2%; margin-top: 3px;">
            <iframe id="ifmPDF_HIN" runat="server" style="height: 90%; width: 48%; position: absolute; margin-top: 1px; margin-left: 1%; border-style: solid; border-color: #ace1d8; min-width: 600px;"></iframe>
        </asp:Panel>
    </div>

C# code..

    string strURL = http://www.somewebsite.com/folder/filename;

    protected void btnBKS_Click(object sender, EventArgs e)
    { pnlPDF_BKS.Visible = true; ifmPDF_BKS.Src = strURL + ".pdf"; }


    protected void btnADD_Click(object sender, EventArgs e)
    { pnlPDF_HIN.Visible = true; ifmPDF_HIN.Src = strURL + "_ADD.pdf"; }

I am looking for solution to view PDF files in iframe when running my application online.

Maybe it's a security problem. If your online web site is using SSL certificate (HTTPS) then you won't be able to embed an iframe from a source without SSL certificate (HTTP). In that case you should upload those PDF files to a site which is using SSL. For example GoogleDocs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM