c# - how to download an excel file from aspx webpage -


i trying fetch excel file stored in bytes database aspx webpage , download , open in .xls format, file getting downloaded .aspx . how resolve this?

i tried:

    private void download(datatable dt)     {           if (dt.rows.count > 0)         {             byte[] bytes = (byte[])dt.rows[0]["xyz"];             response.buffer = true;             response.charset = "";             response.cache.setcacheability(httpcacheability.nocache);             response.contenttype = "application/vnd.ms-excel";             response.binarywrite(bytes);            // response.flush();             response.end();         }     } 

you need set content-disposition header. example:

content-disposition: attachment; filename=your-excel-file.xlsx 

and in code:

response.addheader("content-disposition", "attachment; filename=your-excel-file.xlsx"); 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -