asp.net - Download (Excel Export) with Generic Handler without physically writing a file and without session variable possible? -
i have gridview , want on asp.net web application page , want export data excel.
without updatepanels worked following code:
httpcontext.current.response.clear(); httpcontext.current.response.addheader( "content-disposition", string.format("attachment; filename={0}", filename)); httpcontext.current.response.contenttype = "application/msexcel"; using (stringwriter sw = new stringwriter()) { using (htmltextwriter htw = new htmltextwriter(sw)) { // gridview stuff. // [...] // render htmlwriter response httpcontext.current.response.write(sw.tostring()); httpcontext.current.response.end(); } }
with updatepanels no longer possible think have use generic handler (*.ashx).
is somehow possible pass data generic handler without using session variables or way of doing this?
i don't want phyiscally write file on hdd because it's used 1 time user.
any suggestions?
you can make handler (ashx) accepts querystring, in querystring can put filename of download file. when want have security on files (not file available users), have work in querystring or put info in session on files available download.
Comments
Post a Comment