Hi BCW,
Thanks for you tips.
This is how I am popping the document from a asp:Button in another
part of the application, but when the user submits some form values, I
am trying to pop the word document to them after the post. I was
doing this, initially, but then I realized that the page stopped
processing after this (shockingly enough, i know). So I opted for
having a pop up window run this code, so the parent page can
complete. Everything works great with the pop-up in dev on both IE6
and IE7, but in our UAT env. it only works for IE6.
Thanks,
Allan
string attachment = "attachment ; filename=MyDoc. doc";
Response.ClearC ontent();
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter( sw);
htw.Write(SOMEW ORDTEXT);
HttpContext.Cur rent.Response.C ontentType = "applicatio n/ms-word";
HttpContext.Cur rent.Response.C ontentEncoding =
System.Text.Uni codeEncoding.UT F8;
HttpContext.Cur rent.Response.C harset = "UTF-8";
Response.AddHea der("Content-Disposition", attachment);
Response.Write( @"<html xmlns:o=""urn:s chemas-microsoft-
com:office:offi ce"" xmlns:w=""urn:s chemas-microsoft-com:office:word ""
xmlns=""http://www.w3.org/TR/REC-html40"">");
Response.Write( "<head>");
Response.Write( @"<meta http-equiv=Content-Type content=""text/html;
charset=windows-1252"">");
Response.Write( "<meta name=ProgId content=Word.Do cument>");
Response.Write( @"<meta name=Generator content=""Micro soft Word
11"">");
Response.Write( @"<meta name=Originator content=""Micro soft Word
11"">");
Response.Write( @"<link rel=File-List href=""Doc1_fil es/
filelist.xml""> ");
Response.Write( "<!--[if gte mso 9]><xml<o:Documen tProperties>
<o:Author</o:Author <o:LastAuthor </o:LastAuthor <o:Revision>1 </
o:Revision <o:TotalTime> 1</o:TotalTime>
<o:Created>20 08-05-13T17:47:00Z</o:Created>
<o:LastSaved>20 08-05-13T17:59:00Z</o:LastSaved <o:Pages>1</o:Pages>
<o:Company></o:Company <o:Lines>1</o:Lines <o:Paragraphs>1 </
o:Paragraphs <o:Version>11.9 999</o:Version</o:DocumentPrope rties></
xml><![endif]-->");
Response.Write( "<!--[if gte mso 9]><xml<w:WordDoc ument>
<w:View>Print </w:View <w:DisplayBackg roundShape/>
<w:SpellingStat e>Clean</w:SpellingState <w:GrammarState >Clean</
w:GrammarState <w:PunctuationK erning/ <w:ValidateAgai nstSchemas/>
<w:SaveIfXMLInv alid>false</w:SaveIfXMLInva lid>
<w:IgnoreMixedC ontent>false</w:IgnoreMixedCo ntent>
<w:AlwaysShowPl aceholderText>f alse</w:AlwaysShowPla ceholderText>
<w:Compatibilit y <w:BreakWrapped Tables/ <w:SnapToGridIn Cell/>
<w:WrapTextWith Punct/ <w:UseAsianBrea kRules/ <w:DontGrowAuto fit/
</w:Compatibility <w:BrowserLevel >MicrosoftInter netExplorer4</
w:BrowserLevel</w:WordDocument> </xml><![endif]-->");
Response.Write( @"<!--[if gte mso 9]><xml<w:LatentS tyles
DefLockedState= ""false"" LatentStyleCoun t=""156""</w:LatentStyles> </
xml><![endif]-->");
Response.Write( @"<style><!--@font-face {font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-
family:swiss; mso-font-pitch:variable; mso-font-signature:53687 1559 0
0 0 415 0;}p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-
parent:""""; margin:0in; margin-bottom:.0001pt; mso-
pagination:wido w-orphan; font-size:8.0pt; font-family:""Verdan a"";
mso-fareast-font-family:""Verdan a"";}@page Section1 {size:8.5in
11.0in; margin:.5in .5in .5in .5in; mso-header-margin:.5in; mso-
footer-margin:.5in; mso-paper-source:0;}div.S ection1
{page:Section1; }--></style>");
Response.Write( @"<!--[if gte mso 10]><styletable.Ms oNormalTable
{mso-style-name:""Table Normal""; mso-tstyle-rowband-size:0; mso-
tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:"""";
mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-
margin-bottom:.0001pt; mso-pagination:wido w-orphan; font-size:
8.0pt; font-family:""Verdan a""; mso-ansi-language:#0400; mso-
fareast-language:#0400; mso-bidi-language:#0400; }</style><![endif]--
>");
Response.Write( "</head>");
Response.Write( "<body lang=EN-US style='tab-interval:.5in'> ");
Response.Write( " <div class=Section1> ");
Response.Write( " <p class=MsoNormal ><span style='font-size:
8.0pt;font-family:Verdana' ><o:p>");
Response.Write( sw.ToString());
Response.Write( "</o:p></span></p>");
Response.Write( " </div>");
Response.Write( "</body>");
Response.Write( "</html>");
On Jun 20, 6:58*am, BWC <B...@discussio ns.microsoft.co mwrote:
Absolutely, this can be quite a common situation.
I imagine that if you were to save the .aspx page with a .doc file
extension, you will actually receive the correct file. This is the default
behaviour of IE6 when running in the Internet zone.
You can get more reliable results using headers such as the following:
HttpContext.Cur rent.Response.C ontentType = "applicatio n/ms-word";
HttpContext.Cur rent.Response.A ppendHeader("Co ntent-Disposition",
"attachment ; filename=myWord Doc.doc");
Good luck,
BWC
"allan.s.pal... @gmail.com" wrote:
Hello,
I have an asp.net pop up that is generating a Word document real time
and sending it to the user by sending the appropriate response
headers. When it is run on our development environment it works fine
in both IE6 and IE7. *We recently moved this to our UAT environment
and it works fine for IE7, but IE6 users are getting the option to
only download or save the .aspx page, not the generated .doc file.
Has anyone run into an issue like this before?
Thanks,
Allan- Hide quoted text -
- Show quoted text -