Hi All,
I formatted text in word document as per client requirement and saved the file as web page(.htm) format.
Dot net web application will read the content dynamically from DB /static content and placed it into htm file, finally will create word document.
Issue:
Once downloaded the word document and when I tried to open I got below error message.
I wrote below logic for downlaod document.
bool forceDownload = true;
string ext = Path.GetExtension(fileName);
string filetype = "";
if (ext != null)
{
switch (ext.ToLower())
case ".htm":
case ".html":
filetype = "text/HTML";
break;
case ".txt":
filetype = "text/plain";
case ".doc":
case ".rtf":
case ".docx":
filetype = "Application/msword";
default:
filetype = "application/octet-stream";
}
if (forceDownload)
Response.AppendHeader("content-disposition",
"attachment; filename=" + fileName);
if (filetype != "")
Response.ContentType = filetype;
Response.WriteFile(filePath);
Response.End();
Response.Close();
File.Delete(fileName);
Pelase let me know if you have solution / steps to resolve the issue. Thanks in adavnce.
Regards,
Ravi