1
votes

My question is related to this one:

Is there a way to generate word documents dynamically without having word on the machine

My co-worker told me however that there are some meta tags you can place inside your html head section that will redirect the html and make word open that html page as a word document. I tried it in a framework 3.5 aspx page but it didn't work.

Here are the lines he suggested:

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 11 (filtered)">

I'm going to try different asp frameworks to see if that helps.

Again, if it wasn't clear. The browser would connect to this asp page but then see those tags and redirect the contents to MS word.

4
none of these answers has worked... even though my coworker's link works.Neo42

4 Answers

6
votes

I think your coworker is thinking of MIME types, not meta tags. If you set your MIME type to application/msword, and the computer has Word installed, that will work.

It's possible that some browser plugin or such could be monitoring for <meta> tags, but I think that's a silly abuse of <meta> tags in this case.

5
votes

Generator just describes where the document came from, i.e. it was created using Word. I don;t think this is possible, that way you could have an html page that is basically a virus open the script host automatically for instance. The Best you can do is have the content in a word readable format and use this:

Response.Clear();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");

This will produce a file save dialog.

3
votes

Changing the meta tags won't do anything. You have to change the mime type in the response header to get the browser to open it in word.

Here is a link to microsoft's help page

http://msdn.microsoft.com/en-us/library/ms525208.aspx

0
votes

You need:

<meta http-equiv="Content-Type" content="application/msword">

Now for the diversion in Firefox. The diversion will happen if the user either

a) accepts to open the file in the default handler application

b) the user has instructed firefox to always take the 'open' action for .doc file types