Click here to Skip to main content
12,885,163 members (33,275 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
OS - windows server 2003 and service pack 2

when i try to download ms word file from my web application,am getting a message as
"The file you are downloading cannot be opened by the default program. It is either corrupted or it has an incorrect file type. As a security precaution, it is recommended that you cancel the download"
Any suggestions how can I resolve this warning?
Posted 28-Nov-12 20:16pm
Richard MacCutchan 29-Nov-12 6:18am
Check the file.
Er. Vikas Sangal 1-Dec-12 1:48am ur backend code.
Mydsh 1-Dec-12 11:18am
Here is my backend code

string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbconnect"];
NewDAL dalObj = new NewDAL();
private DataSet dataSet;
protected void Page_Load(object sender, EventArgs e)

string MODE = Request.QueryString["MODE"];
ClientScript.RegisterHiddenField("__EVENTTARGET", "lbtn_search");
if (Session["CurrentFilter"] == null)
Session["CurrentFilter"] = "ALL";
HttpContext.Current.Session["PathLineMsg"] = "List of Relationship(s)".ToString();
if (MODE == "HTML")
if (MODE == "PDF")
if (MODE == "PRINT")
private void HTMLReport()
int RelationsID = Convert.ToInt32(Request.QueryString["Rid"]);
HttpContext.Current.Session["RelationsID"] = RelationsID;
//ClientScript.RegisterStartupScript(this.GetType(), "string", "javascript:PrintResults();", true);
if (impersonateValidUser("MSWord", "", "abcd123!"))
lblError.Visible = false;
WordApp oWord = new WordApp();

oWord.OpenAndPrint(wordPath, pdfpath);


while (System.Diagnostics.Process.GetProcessesByName("WINWORD.EXE").Length > 0)






This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100