c# - Why my code throws thread aborted error? -


i using code download file throws error. please me in handling it.

thread being aborted.

protected void download_click(object sender, eventargs e) {     try     {         string filepath = convert.tostring(attachment);         string fullfilepath = ("../../siteimages/" + "donald.jpg");         response.clear();         response.clearheaders();         response.clearcontent();         response.addheader("content-disposition", "attachment; filename=\"" + path.getfilename(fullfilepath) + "\"");         response.contenttype = contenttype;         response.transmitfile(fullfilepath);         //mnglogs.insertauditsinfo("tender downloaded via" + " " + mnglogs.pagename, mnglogs.usermacaddress, mnglogs.useripaddress, userid, "download");         //response.end();     }     catch (exception ex)     {         utility.msg_error(master, ex.message);     } } 

could download approach work?

try {     using (var client = new webclient())     {         client.downloadfile(urltofileoninternet, pathtofileoncomputer);     } } catch (exception ex) {     utility.msg_error(master, ex.message); } 

hope helps.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -