Doc文件不从asp.net中的UserControl下载

我有用户控件,其中包含一个包含候选数据的网格。 有一个列候选名称和模板字段链接按钮。 我附加了一个rowcommand事件,我正在下载一个word文件。 我有下载doc文件代码,它从简单的网页下载我的doc文件,但是这段代码不能用于用户控制。 任何人都可以帮我解决这个问题。 它提供错误响应不可用

     Candidate Name   <asp:LinkButton ID="lnkResume" CommandName="Download" CommandArgument='' runat="server" Text='' ToolTip=''>     protected void grdCandidate_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Download") { byte[] Attachment = null; string Extension = string.Empty; string Resume = "Resume"; ClsCandidateManager objCandidateManager = new ClsCandidateManager(); ClsSecureManager objSecureManager = new ClsSecureManager(); Attachment = objCandidateManager.GetCandidateAttachment(Convert.ToInt32(e.CommandArgument), out Extension); if (Attachment != null && Attachment.Length > 0) { try { Response.Clear(); Response.Buffer = true; Response.Charset = ""; if (Extension == ".pdf") { Response.ContentType = "application/pdf"; } else { Response.ContentType = "application/vsd-msword"; } Response.AddHeader("content-disposition", "attachment;filename=" + Resume + Extension); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(Attachment); Response.Flush(); Response.End(); } catch (Exception ex) { string str = ex.Message + ex.InnerException; } } else { //ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "alert('Resume is not Uploaded !');"); } } } catch (Exception ex) { string str = ex.Message + ex.InnerException; } 

使用UpdatePanel,如下所示,