Click here to Skip to main content
Rate this: bad
good
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 21:16pm
Mydsh278
Comments
Richard MacCutchan at 29-Nov-12 6:18am
   
Check the file.
Er. Vikas Sangal at 1-Dec-12 1:48am
   
pls.post ur backend code.
Mydsh at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
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