Error : Message : Thread was being aborted. StackTrace : at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.AbortCurrentThread() at ucpurchaseorderdetails.btnforcedownload_Click(Object sender, EventArgs e) in order-details.ascx.vb:line 164
ASPX.VB
Protected Sub btnforcedownload_Click(sender As Object, e As EventArgs)
Try
Dim commandArgs() As String = CType(sender, LinkButton).CommandArgument.ToString.Split(New Char() {Microsoft.VisualBasic.ChrW(44)})
Dim fudoc As String = commandArgs(0)
Dim dcno As String = commandArgs(1)
Dim bytesaa As Byte()
Dim t_dext As String
dbconn.OpenConnection()
Dim cmd As New SqlCommand()
cmd.CommandText = "select t_text, t_dext from t_docs where t_orno=@t_orno AND t_dcno=@t_dcno"
cmd.Parameters.AddWithValue("@t_orno", fudoc)
cmd.Parameters.AddWithValue("@t_dcno", dcno)
cmd.Connection = dbconn.con
Dim sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Read()
bytesaa = DirectCast(sdr("t_text"), Byte())
t_dext = sdr("t_dext").ToString()
dbconn.CloseConnection()
My.Response.Clear()
Response.ClearHeaders()
My.Response.Buffer = True
My.Response.Charset = ""
My.Response.Cache.SetCacheability(HttpCacheability.NoCache)
My.Response.ContentType = "application/pdf"
My.Response.AppendHeader("Content-Disposition", "attachment; filename=" + fudoc + t_dext)
My.Response.BinaryWrite(bytesaa)
My.Response.Flush()
My.Response.End()
Catch ex As Exception
Me.log.LogError(ex)
End Try
End Sub
ASPX
<asp:LinkButton ID="btnforcedownload" runat="server" OnClick="btnforcedownload_Click" CommandArgument='<%# Eval("fudoc") + "," + Convert.ToString(Eval("dcno")) %>'><i class="fa fa-download"></i> </asp:LinkButton>