Tag: httpcontext

导出使用HttpContext.Current.Response是造成问题

我正在开发一个使用asp.net/C#/HTML5/bootstrap的网站。 其中一个要求是将文档导出为Excel和/或PDF。 我能够导出(成功)使用以下代码片段(这是Excel代码段): HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filename); HttpContext.Current.Response.BinaryWrite(xlsBytes); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); 我遇到的问题是,在运行之后,似乎是停止页面生命周期中的轨道。 作为一个例子,用户点击导出button,调用JavaScript抛出一个“请稍候”模式对话框,并提交表单: <script src="../Scripts/waitingFor.js"></script> <script type="text/javascript"> function pleaseWait() { waitingDialog.show("Building File<br/>…this could take a minute", { dialogSize: "sm", progressType: "warning" }); form = document.getElementById("frm_contentMaster"); form.submit(); } </script> javascript包含文件: /** * Module for displaying "Waiting for…" dialog using Bootstrap […]