Opening word documents stored in SQL Server using ASP.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, i'm hoping that somebody can point me in the right direction with my
problem.

I have been tasked with creating a simple browser based application that
will allow the user to upload Word documents to SQL Server and then retrieve
them when needed. Storing the Word document seems to be no problem but where
I am stuck is on retrieving them and then displaying the Word documents as
through ASP.NET it will be on the server i think.

Does anybody know of any articles, best practices or advice that will allow
me to crack this problem.

Many thanks for your guidance in advance.

R
 
I am sure there are some articles. The basic of outputting as a different
type is changing the mime type of the response. To get the document out, you
will stream directly to HTTP, as it is the most efficient. What this means is
the display page is an ASPX without any ASPX tags (just the @ directive) and
you will be manipulating the type in the response header in your CodeBehind.

In addition, you may have to set up IIS to recognize Word as a valid MIME
type.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
On your aspx page that's supposed to show the word document write:

<%@ Page language="c#" Codebehind="ExportToWord.aspx.cs"
AutoEventWireup="false" Inherits="WebTry001.Graph.ExportToWord" %>
<% RenderWordData (); %>

and on the code-behind write:

protected void RenderExcelData ()
{
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition",
"inline;filename=MyReport.doc");

//here save the content of your document to Response.OutputStream ...

}

hope it helps.
 
Many thanks for your help.

If anybody knows of any documents or sample applications to look at I would
be gratefull if you could provide the URL.

Thanks

R
 
Back
Top