webforms - Generating and downloading an `Excel` document breaks `ASP.net` LoginStatus -
in asp.net web application have page shows (not complicated) table. have implemented button when (registered) members clicks on it, browser downloads table excel
document
the code generate excel
follow:
dim response httpresponse = httpcontext.current.response ' first let's clean response.object response.clear() response.charset = "" dim filename string = mappath("~/ex1.xls") ' set response mime type excel response.contenttype = "application/vnd.ms-excel" response.addheader("content-disposition", "attachment;filename=""" & filename & """") ' create string writer using sw new stringwriter() using htw new htmltextwriter(sw) ' instantiate datagrid dim dg new datagrid() dg.datasource = dt dg.databind() dg.rendercontrol(htw) response.write(sw.tostring()) response.[end]() end using end using
the problem code breaking somehow aspn.net
loginstatus
when try log out after downloading excel
(the "log out" buttom visible @ application) every click on buttom download same excel
over , on (once per click). if reload window or change page "log out" work again.
this "log out" link when inspecting chrome:
<a id="ctl00_ctl00_maincontent_loginstatus1" href="javascript:__dopostback('ctl00$ctl00$maincontent$loginstatus1$ctl00','')">log out</a>
i have tried make excel
download other page using:
onclick="window.document.forms[0].target='_blank';"
and opens new tab, download excel
, close tab (fast process) still keeps breaking logout link.
and run out of ideas, help, code, hint or whatever possible solution fix problem welcome.
open new page within blank target, , let new page generate excel
Comments
Post a Comment