Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Richard MacCutchan 29-Nov-12 6:18am    
Check the file.
Er. Vikas Sangal 1-Dec-12 1:48am    
pls.post 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();
BindData();
if (MODE == "HTML")
{
HTMLReport();
}
if (MODE == "PDF")
{
PDFReport();
}
if (MODE == "PRINT")
{
PrintReport();
}
private void HTMLReport()
{
int RelationsID = Convert.ToInt32(Request.QueryString["Rid"]);
HttpContext.Current.Session["RelationsID"] = RelationsID;
HtmlRendering(RelationsID);
//ClientScript.RegisterStartupScript(this.GetType(), "string", "javascript:PrintResults();", true);
}
if (impersonateValidUser("MSWord", "", "abcd123!"))
{
lblError.Visible = false;
WordApp oWord = new WordApp();

oWord.OpenAndPrint(wordPath, pdfpath);

undoImpersonation();

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

System.Windows.Forms.Application.DoEvents();

System.Threading.Thread.Sleep(100);

}

ReadPdfFile(pdfpath);

}

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900