You need to specify correct content type: "application/vnd.ms-word":
return File(fs, "application/vnd.ms-word", "documentfile.doc");
Pergunta
I am trying to open/download a word file on a browser using C#. The process is working for PDF files, but not for .doc files. It donwloads as a "application/octet-stream (100 kB)"
My code is:
FileStream fs = new FileStream(Server.MapPath(@"~\Content\documetfile.doc"), FileMode.OpenOrCreate, FileAccess.ReadWrite);
return File(fs, "documentfile.doc");
What do i need to do to make it download as a word file ?
Solução
You need to specify correct content type: "application/vnd.ms-word":
return File(fs, "application/vnd.ms-word", "documentfile.doc");