views:

301

answers:

4

My question is related to this one:

http://stackoverflow.com/questions/326941/is-there-a-way-to-generate-word-documents-dynamically-without-having-word-on-the

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.

+5  A: 

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.

Colin
+3  A: 

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

Zoidberg
how do I change the mime type?
Neo42
its in the response object on the server side.Here is a good linkhttp://msdn.microsoft.com/en-us/library/ms525208.aspx
Zoidberg
A: 

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

Crimson
+6  A: 

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.

John Feminella
How would I set my mime type to that?
Neo42