Cassie Mod

Cassie Mod

  • NA
  • 488
  • 70.6k

thread aborted asp.net and c#

Apr 18 2016 10:55 AM
hi guys,
 
I get the following error. when trying to open a document ( from a filestream) in asp.net /c#.
 
protected void LinkButtonOpenFile_OnClick(Object sender, EventArgs e)
{
try
{
using (var connection = DatabaseLayer.OpenConnection())
{
LinkButton link = (LinkButton)sender;
var FileName = link.Text;
var extention = Path.GetExtension(FileName);
var partnerresourseID = OrganisationLogic.GetPartnerResourceIdByOrgIdAndFileName(sender, connection, null, Convert.ToInt32(ViewState["OrgID"]), FileName);
var logo = OrganisationLogic.GetPartnerResourceById(connection, null, partnerresourseID);
Response.ClearContent();
Response.Buffer = false;
Response.ContentType = ProjectAttachmentLogic.GetContentType(extention);
Response.AddHeader("Content-disposition", "attachment; filename=" + FileName);
Response.BinaryWrite(logo.Data);
Response.OutputStream.Write(logo.Data, 0, logo.Data.Length);
Response.OutputStream.Flush();
Response.End(); // here it crashes and said " Thread is aborted".
               }
}
catch (Exception ex)
{
throw;
}
}
 

Answers (1)