Rendering WordML from ASP.NET

Discussion in 'ASP .Net' started by Biff, Mar 10, 2007.

  1. Biff

    Biff Guest

    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
    Biff, Mar 10, 2007
    #1
    1. Advertising

  2. Biff

    MULTISY Guest

    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" <> wrote in message
    news:...
    >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
    >
    MULTISY, Mar 16, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evert
    Replies:
    0
    Views:
    927
    Evert
    Jul 11, 2003
  2. Tom Frey

    WordML XML to PDF

    Tom Frey, Aug 5, 2003, in forum: XML
    Replies:
    1
    Views:
    639
    Eoin Campbell
    Aug 13, 2003
  3. Sascha Kerschhofer

    XSL:FO => WordML

    Sascha Kerschhofer, Apr 20, 2004, in forum: XML
    Replies:
    0
    Views:
    640
    Sascha Kerschhofer
    Apr 20, 2004
  4. Clifford W. Racz
    Replies:
    5
    Views:
    732
    Clifford W. Racz
    May 20, 2004
  5. Me
    Replies:
    1
    Views:
    589
    Alvin Bruney [MVP]
    Aug 7, 2006
Loading...

Share This Page