ASP.net下载文件在后续调用中失败

时间:2016-07-13 00:08:25

标签: javascript c# asp.net download

我有一个奇怪的情况。我有一个带有Linkbuttons的网格。代码在下面

 <asp:LinkButton runat="server" OnClick="DownloadPDF" Text=<%# Eval("Number")%> CommandArgument= <%# Eval("ID")%> > <%# Eval("ID")%> </asp:LinkButton>


    protected void DownloadPDF(object sender, EventArgs e)
    {
        int ID= Convert.ToInt32(((LinkButton)sender).CommandArgument);
        string Number= ((LinkButton)sender).Text;

        var pdf = WS.GetPdf(ID);


        Response.Clear();
        Response.ClearHeaders();
        Response.ClearContent();
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=ID_{0}.pdf", Number));
        Response.OutputStream.Write(pdf.Content, 0, pdf.Content.Length);
        Response.Flush();
        Response.End();
    }

点击第一次工作正常(下载文件),下次不断收到错误信息&#34;您尝试访问的页面已过期&#34;

0 个答案:

没有答案