我正在使用下面的代码下载Excel文件。一旦运行
Response.End()
调用,我想关闭窗口。然而,这并没有发生。请看下面我已经写好的代码。'Write it back to the client
Dim filename As String = "FullExtract_" & Now.Year.ToString & Now.Month.ToString & Now.Day.ToString & ".xlsx"
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("content-disposition", "attachment; filename=" & filename)
Response.BinaryWrite(pck.GetAsByteArray())
Response.End()
'cursor not reaching to below code
Page.ClientScript.RegisterStartupScript(Me.GetType(), "closedownload", "JavaScript:window.close(); return false;")
如何关闭窗口?
Response.End
时,它会停止页面的执行,因此它不会进一步处理页面。请查看此链接:http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx。 - Lukasz M