Search code examples
c#asp.netiframegoogle-docsgoogle-document-viewer

No preview available iframe aspx page


Please help,I know this question has been asked before but I didn't get any solution ...I have an aspx page which has to display some files of types docx and xlsx... I am trying to use iframe with google docs viewer, but an error is thrown:No preview available. Below is my code in my aspx page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
    body {
     margin: 0px;
    }
    .doc {
       border: 0; width: 100%; height: 100%;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <iframe class="doc" src="https://docs.google.com/gview?url=http://localhost:2342/Project-Test-Temp/Uploaded/Save.docx"&embedded=true"></iframe>
     </div>
    </form>
</body>
</html>

Here is a working example:

http://jsfiddle.net/kbu2gsfm/

I have tried this:

<iframe class="doc" src="../UploadedImages/Save.docx"></iframe>

But it is downloading file !!

How can I resolve this issue and display my word and excel file normally? I appreciate your helps


Solution

  • Your source link is:

    https://docs.google.com/gview?url=http://localhost:2342/Project-Test-Temp/Uploaded/Save.docx

    The issue is that docs.google.com cannot read a file from your local file server.

    If you want to use that service, you must upload the file to a public location