Hi,
I have page called filedownload.aspx , it contains grid and in grid they are three columns and in one of the column there is button which says Download , when user clicks on that button it picks file id and gives the download box to user with three options Open save and cancel .
Now the problem is that when user clicks on the download button in grid it gives this ERROR: INTERNET EXPLORER CANNOT DOWNLOAD FILEDOWNLOAD.ASPX FROM ABC.XYZ.COM (MY URL EXAMPLE) INTERNET EXPLORER WAS NOT ABLE TO OPEN THIS SITE .THE REQUEST SITE IS EITHER UNAVAILABLE OR CANNOT BE FOUND .
ONE MORE THING IS THT RECENTLY WE IMPLEMENTED SSL AND FROM HTTP WE MOVE TO HTTPS WITH NAME CHANGE IN URL ALSO BFEORE IT WAS AND NOW ITS .
NOW WHEN I CHANGE THE URL TO OLD ONE THE PAGE IS WORKING FINE .
CAN ANYONE HELP ME ON THIS ?
My code :my code:
protected void gdvfiledownload_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Download") { int indexfile = Convert.ToInt32(e.CommandArgument.ToString()); GridViewRow row = gdvfiledownload.Rows[indexfile]; string fileuserid = Ldapinfo.getName(Page.User.Identity.Name); string batchfilename = Convert.ToString(row.Cells[0].Text.ToString()); //string requestedby = Convert.ToString(row.Cells[3].Text.ToString());
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString.ToString());
cn.Open();
con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring "].ConnectionString.ToString());
con.Open();
DataSet ds = new DataSet();
//SqlDataAdapter da = new SqlDataAdapter("sp_Insert_CAV2_File", cn);
SqlCommand sqlCommand = new SqlCommand("sp_proc ", cn);
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Parameters.AddWithValue("@batch_name", batchfilename);
sqlCommand.Parameters.AddWithValue("@curr_user", fileuserid);
SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
da.Fill(ds);
StringBuilder strFD = new StringBuilder();
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
for (int j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
{
strFD.Append(ds.Tables[0].Rows[i][j].ToString());
strFD.Append(" ");
}
strFD.AppendLine();
}
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Notepad.txt");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.text";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Response.Write(strFD.ToString());
Response.End();
cn.Close();
con.Close();
cn.Dispose();
con.Dispose();
}
}
catch (Exception ex)
{
lblfilemess.Text = ex.Message.ToString();
}
}
THANKS, SMARTDEV