Opening a file of any extension in an iframe
<p>I have a web application in which i need to open any files in standard formats such as .doc/docx/.csv/.txt/.xls in an iframe . How can I achieve this ? I tried using the sample code below but it is not opening all the file formats in the iframe. I am getting some XML error.</p>

<pre><code>var ext = GetExtension(fileName);
        switch (ext)
        {
            case "pdf":
                Response.ContentType = "Application/pdf";
                break;
            case "htm":
            case "html":
                Response.ContentType = "text/html";
                break;
            case "txt":
                Response.ContentType = "text/plain";
                break;
            case "doc":
                Response.ContentType = "Application/vnd.ms-word";
                break;
            case "xls":
            case "csv":
                Response.ContentType = "Application/vnd.ms-excel";
                break;
            case "ppt":
            case "pps":
                Response.ContentType = "Application/vnd.ms-powerpoint";
                break;
            default:
                Response.ContentType = "Application/unknown";
                break;
        }
        if (Response.ContentType != "Application/unknown")
        {
            Response.Flush();
            Response.WriteFile(fileName);
            Response.End();
        }
</code></pre>
