Correction to Code - WordML Document not showing up correctly

M

Meena Bhashyam

Hi,
Please disregard previous code. This is the actual code:

Dim xmlDoc As New XmlDocument
xmlDoc.Load("D:\VisualStudioProjects\TestXML\TestXML\bin\HelloWorld.xml.doc")
Response.ContentType = "application/word"
Response.Write(xmlDoc.OuterXml)

In response, my browser tries to open up a asp.net server page. See below
for contents. Can anyone tell me what I am doing incorrect?

Thanks,
Meena



<?xml version="1.0"?><?mso-application
progid="Word.Document"?><w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"><w:body><w:p><w:r><w:t>Hello, World.</w:t></w:r></w:p></w:body></w:wordDocument>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtNTMwNzcxMzI0Ozs+OvdQZMod1ytpo8PAa36fRK0Ptqc=" />

<input type="submit" name="Button1" value="View Letter" id="Button1"
style="height:64px;width:224px;Z-INDEX: 101; LEFT: 272px; POSITION: absolute;
TOP: 120px" />
</form>
</body>
</HTML>
 
J

Jean-Guy Marcil

Meena Bhashyam was telling us:
Meena Bhashyam nous racontait que :
Hi,
Please disregard previous code. This is the actual code:

Dim xmlDoc As New XmlDocument
xmlDoc.Load("D:\VisualStudioProjects\TestXML\TestXML\bin\HelloWorld.xml.doc")
Response.ContentType = "application/word"
Response.Write(xmlDoc.OuterXml)

I think you need
Response.ContentType = "application/msword"
instead of
Response.ContentType = "application/word"
See
http://www.asptutorial.info/sscript/ContentType.asp

In response, my browser tries to open up a asp.net server page. See
below
for contents. Can anyone tell me what I am doing incorrect?

Thanks,
Meena



<?xml version="1.0"?><?mso-application
progid="Word.Document"?><w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"><w:body><w:p><w:r><w:t>Hello,
World.</w:t></w:r></w:p></w:body></w:wordDocument> <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtNTMwNzcxMzI0Ozs+OvdQZMod1ytpo8PAa36fRK0Ptqc=" />

<input type="submit" name="Button1" value="View Letter" id="Button1"
style="height:64px;width:224px;Z-INDEX: 101; LEFT: 272px; POSITION:
absolute;
TOP: 120px" />
</form>
</body>
</HTML>

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Meena Bhashyam

Actually, there were a couple of things. You were correct, basically the
content type had to be
set to "application/msword", and I also had to set the correct mime type on
IIS.
In addition, I had to add
Response.Flush()
Response.End()
to stop the html from getting inserted. This solved my problem.

Thank you!
Meena
 

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

Top