By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,856 Members | 1,986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,856 IT Pros & Developers. It's quick & easy.

Rendering WordML from ASP.NET

P: n/a
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

Mar 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Biff" <bi******@gmail.comwrote in message
news:11********************@c51g2000cwc.googlegrou ps.com...
>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

Mar 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.