问导出文件到客户端下载后,页面左下角出现错误提示,然后页面按钮点击就没有效果,重新打开页面 ,恢复正常,
再点下载,然后又错误
- C# code
System.Text.StringBuilder outputBuffer=new System.Text.StringBuilder();string filename=DateTime.Now.ToString("yyyyMMddhhmmss")+".txt";outputBuffer.AppendFormat("{0}",savetxt);System.Web.HttpContext.Current.Response.Clear();System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+filename);//System.Web.HttpContext.Current.Response.AddHeader("Content-Length", size);System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"; System.Web.HttpContext.Current.Response.Charset = "UTF-8";System.Web.HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(outputBuffer.ToString()));System.Web.HttpContext.Current.Response.End();
savetxt为要导出下载的文本。上面代码为点击按钮后执行,
下载文件到本地后,页面右下角就出现错误,并且按钮失效,页面重新打开才能正常
------解决方案--------------------------------------------------------
帮你顶上去