consultancy chorley ASP.NET Server Side Scripting Wigan
Website Development Radcliffe

A Coder's Notes

Email :
bespoke invoice systems Standish Information Technology Advice Worsley
    development systems Ramsbottom
data manipulation Farnworth access databases Whitefield SQL connections Atherton
online accessible software Leyland software compatible Coppull

Get connected and Online Tottington
remote management Makerfield code and design Aspull

Serve Up HTML as Word...ASP.Net - 06/06/2012

If for some randon reason you want to send your html code as a word document then you need the following code somewhere in the "sub page_load" section.

 Response.AppendHeader("Content-Type", "application/msword")
 Response.AppendHeader ("Content-disposition", "attachment; filename=Myfile.doc")

What this does is instead of IIS starting by sending the page as a webpage it sends it as a word document.  Don't ask me to explain, I don't know the exact details but the browser gets a message saying "This ain't ur standard webpage our kid...this is a word document" and your browser thinks " in this ere list if it's a word document I gotta open word to show this...".  If you don't get word then it's either not installed or your browser's not configured to open word when it sees "application/msword"

Word will actually parse html acceptably well.  Especially if it's simple HTML. 

Post A Comment

Name Comment
programming services specialist
Valid XHTML 1.0 Transitional