none
Issue with download the file in aspx RRS feed

  • Question

  • 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


    • Edited by AnkitKumar2016 Monday, August 19, 2019 8:58 AM
    • Moved by CoolDadTx Monday, August 19, 2019 1:38 PM ASP.NET related
    Monday, August 19, 2019 8:17 AM

All replies

  • Hello,

    You have indicating trying different solutions on the web, have you considered asking in the ASP.NET forums?

    https://forums.asp.net/


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, August 19, 2019 10:50 AM
  • I did not find right  solution any where. if you have please provide solution. Any approach without jquery or java script? How can we achieve in asp.net by c# code.

    Please reply.

    Thanks

    Monday, August 19, 2019 1:49 PM