我已經編寫代碼,在代碼後面下載它後打開一個Word文檔。文檔打開正常,但不是以Word格式保存。當我打開它時,它會要求選擇打開文件的格式。從後面的代碼下載後打開一個word文件(asp.net)
的代碼如下:
string FullFilePath = "D:\\ASP\\ASP.doc";
FileInfo file = new FileInfo(FullFilePath);
if (file.Exists)
{
Response.ContentType = "application/vnd.ms-word";
Response.AddHeader("Content-Disposition", "inline; filename=\"" + txtDate.Text + "\"");
Response.AddHeader("Content-Length", file.Length.ToString());
Response.TransmitFile(file.FullName);
}
嘗試response.contenttype =「application/doc」 –