Click here to Skip to main content
15,125,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
PLease help me, 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:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisplayFile.aspx.cs" Inherits="Pages_DisplayFile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <style type="text/css">
    body {
     margin: 0px;
    .doc {
       border: 0; width: 100%; height: 100%;
    <form id="form1" runat="server">
     <iframe class="doc" src=""&embedded=true"></iframe>

Here is a working example:

Edit fiddle - JSFiddle[^]

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

What I have tried:

I have tried this:

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

But it is downloading file !!
Updated 6-Mar-17 7:38am

1 solution

Actually, the X-Frame-Options is not turn on for domain. SO it, should work, my guess is it could be the JavaScript error somewhere in the code?

This is because the domain has X-Frame-Options turn on.

"X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking."

Scan results for[^]
H.AL 7-Mar-17 7:55am
Thank you for your answer, but no errors... I solved by publishing my doc file on a public server, the issue is that cannot read a file from local file server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900