Free Support Forum -

Generated Word File not opening up in the browser


I’m encountering a problem when trying to open a served word file in the browser.
The file is saved directly to the response object, with OpenInWord option.

the browser prompts to open/save the file but regardless of which option
is chosen still pops up a save dialog not giving an option to actually open the file.

Everything works fine on the dev machine but on the live site I am having challenges.

The live server is a win2k/iis5, whereas dev box is win2k3/iis6.

I did check the mime mappings thinking that maybe they are incorrect but
.doc is registered and the browser does seem to recognize the file as a word

Also, I seem to be having trouble opening a word file located on the network share
throught the Aspose.Word object, the error I get returned says invalid Username/password which I am not sure how to supply.

Again it works ok from the dev server trying to access the same share.
There are no apparent issues if trying to browse to the file in windows explorer
however. I can browse to the share without logging in since both computers are part of the same domain.

Any thoughts on either/both of these issues??

Thanks, Ilia

I think these are two separate issues.

1. Aspose.Word cannot really control what happens on the client browser once it streams the document to it. If it opens okay in one configuration and does not open in another - the problems must be in the configuration. It's more likely to be related to the version of the browser and MS Office version, rather than to the IIS or server OS version. There might be some security settings in MS Office or in the browser preventing you from opening the document. Sorry, I don't have more info on this one, I think search in MS knowledge base could help.

2. If I understand your situation correctly: Aspose.Word runs on the server in an ASP.NET application and you try to open a file that's on another computer accessible via a share. In this situations you need to be aware that the ASP.NET application probably runs under ASPNET user account that might have no access to the share. Actually it depends on IIS and ASP.NET authentication settings, you need to look at them carefully. You might have them set up differently on your development machine or something along those lines.

Roman, the client computer in both instances is the same, so I am sort
of ruling out the client configuration issue.

It more seems like the server object not supplying the correct mime type
in the response stream.

If you could shed more light on the way the Aspose.Word object
formats the response’s MIME type and how the OpenInBrowser vs
OpenInWord bits are set that would help I suppose.

Thanks, Ilia

I'm pretty sure I posted source code of this Save method before, 
but I couldn't find it so I post it again. I think this approach is well known
and described on many developers websites.



//Add header

if(saveType == SaveType.OpenInWord)

response.AddHeader("content-disposition","attachment; filename=" + fileName);


response.AddHeader("content-disposition","inline; filename=" + fileName);

//Set content type

switch (fileFormat)


case SaveFormat.FormatDocument:

response.ContentType = "application/msword";


case SaveFormat.FormatText:

response.ContentType = "text/plain";


case SaveFormat.FormatHtml:

response.ContentType = "text/html";



throw new ArgumentException("Invalid file format requested.");


Save(response.OutputStream, fileFormat);

Roman, thank you for your quick responses.

We have figured out the problem which seems to be related to
the IE recognizing documents coming from a Https websites differently
from Http.

Thanks again, Ilia.