Rendering WordML from ASP.NET

B

Biff

I have a WordML file that I want to render in the browser in word via
ASP.NET. If I use Response.Redirect("filename.xml") in the ASP.NET
codebehind I can get it to work. I would prefer to use set the
ContentType to the appropriate value and write the actual XML text to
the Response object, but I can't get that to work. I've tried the
following-

//***************************************************************
// This shows the contents as XML
//***************************************************************
string fileContents;
using (System.IO.StreamReader sr = new
System.IO.StreamReader(@"c:\temp\quizxml.xml"))
{
fileContents = sr.ReadToEnd();
}

Response.ContentType = "text/xml";
Response.Write(fileContents);


//***************************************************************
// This puts a a Word dialog that says "the XML file Default.aspx
cannot be opened
// because there are problems with the contents
//***************************************************************
string fileContents;
using (System.IO.StreamReader sr = new
System.IO.StreamReader(@"c:\temp\quizxml.xml"))
{
fileContents = sr.ReadToEnd();
}

//Response.Clear();
Response.ContentType = "application/msword";
Response.Write(fileContents);



//***************************************************************
// This shows the contents as XML
//***************************************************************
string fileContents;
using (System.IO.StreamReader sr = new
System.IO.StreamReader(@"c:\temp\quizxml.xml"))
{
fileContents = sr.ReadToEnd();
}

//Response.Clear();
Response.ContentType = "application/msword-xml";
Response.Write(fileContents);


My final goal is to allow the document to be edited with Word, then
intercept the save event in the ASP.NET code to grab the document and
process within ASP.NET rather than granting the client user rights to
save a file to the server.

Any ideas or suggestions?

Biff Gaut
Gaithersburg, MD
 
M

MULTISY

To render WordML file as HTML; Microsoft provides the file Word2Html.xsl
that will do just it. Although be warned large word documents will take a
long time to transform.

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top