Issue with download the file in aspx

  • Thread starter Thread starter AnkitKumar2016
  • Start date Start date
A

AnkitKumar2016

Guest
In given code file is downloading successfully but all code not executing.

protected void GridViewTicketResult_RowCommand(object sender, GridViewCommandEventArgs e)
{
var row = GridViewTicketResult.DataKeys[Convert.ToInt32(e.CommandArgument)].Values;
var path =row["url"].ToString()
bool isURL=true;
if (isURL)
{
DivCustomerSignature.Visible = true;
btnCustomerSignature.Text = "Sign as " + Convert.ToString(Session["ContactName"]);
CheckBox1.Checked = false;
hdnDocumentNumber.Value = DocumentNumber;
hdndb.Value = Db;

string url = path;

WebClient webClient = new WebClient();
byte[] Content = webClient.DownloadData(url);
string fileName = (url.Split('/')[url.Split('/').Length - 1]).Split('.')[0];

Response.ContentType = "text/pdf";
Response.AddHeader("content-disposition", "attachment; filename=" + input.DocumentNumber + ".pdf");
Response.BufferOutput = true;
Response.OutputStream.Write(Content, 0, Content.Length);
Response.Flush();
//Response.End();

//byte[] bytes = webClient.DownloadData(url);
//string fileName = (url.Split('/')[url.Split('/').Length - 1]).Split('.')[0];
//Response.ContentType = "text/pdf";
//Response.AppendHeader("Content-Disposition", "attachment; filename=" + input.DocumentNumber + ".pdf");
//Response.BinaryWrite(bytes);
//Response.Flush();
//Response.SuppressContent = true;

}
}



This code not running.

DivCustomerSignature.Visible = true;
btnCustomerSignature.Text = "Sign as " + Convert.ToString(Session["ContactName"]);
CheckBox1.Checked = false;
hdnDocumentNumber.Value = DocumentNumber;
hdndb.Value = Db;

I have been checked several solution on internet but did not find desired solution. Please provide needful solution.

Thanks

Continue reading...
 
Back
Top