本文介绍了Word文档不会保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 该网站拒绝显示此网页 HTTP 403 最有可能原因: •本网站要求您登录。 b $ bThe website declined to show this webpage HTTP 403Most likely causes:•This website requires you to log in.//DOC download private void DownloadDoc() { object fileName = LabelFirstNameFromDb.Text + "_" + LabelLastNameFromDb.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd") + "." + DropDownListDownload.SelectedItem.Text; var db = new KnowItCvdbEntities(); SPWeb theSite = SPControl.GetContextWeb(Context); SPUser theUser = theSite.CurrentUser; string strUserName = theUser.LoginName; var theEmpl = (from p in db.EMPLOYEES where p.username == strUserName select p).FirstOrDefault(); if (theEmpl != null) { object missing = Missing.Value; object start1 = 0; var wordApp = new ApplicationClass(); Microsoft.Office.Interop.Word.Document myDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing); object fileStream = new FileStream(Server.MapPath("~/Upload/") + fileName, FileMode.Create); Range rng = myDoc.Range(ref start1, ref missing); try { myDoc.SaveAs(ref fileStream, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); wordApp.Visible = true; const char newLine = (char)11; //REPEATER KOMMER HÄR SetCustomizedCvThreeTechSkill(); for (int i = 0; i < RepeaterStrongestSkill.Controls.Count; i++) { var skill = (Label)RepeaterStrongestSkill.FindControl("skill" + i); var pie = (Image)RepeaterStrongestSkill.FindControl("pie" + i); if (skill != null && pie != null) { rng.InsertBefore(" " + skill.Text); string pieUrl = pie.ImageUrl; rng.InlineShapes.AddPicture(pieUrl, ref missing, ref missing, ref missing); } else { break; } } rng.InsertBefore(newLine.ToString()); rng.InsertAfter(newLine.ToString()); rng.InsertBefore(newLine + LabelPosFromDb.Text + " " + LabelFirstNameFromDb.Text + " " + LabelLastNameFromDb.Text + newLine + LabelAboutFromDb.Text + newLine); string imageKnowItLogo = ImageKnowIt.ImageUrl; rng.InlineShapes.AddPicture(imageKnowItLogo, ref missing, ref missing, ref missing); rng.InsertBefore(newLine.ToString()); string imageProfPic = ImageProfPic.ImageUrl; rng.InlineShapes.AddPicture(imageProfPic, ref missing, ref missing, ref missing); rng.InsertAfter(newLine + LabelBackground.Text + newLine + LabelDoB.Text + LabelDoBFromDb.Text + newLine + LabelPhone.Text + LabelPhoneFromDb.Text + newLine + LabelEmail.Text + LabelEmailFromDb.Text + newLine + LabelPosition.Text + LabelPositionFromDb.Text + newLine); //PERSONAL SKILLS //LANGUAGES string languages = string.Empty; var lbLanguages = new Label(); foreach (var vLang in BulletedListLanguages.Items) { languages += " - " + vLang + newLine; } lbLanguages.Text = newLine + LabelLanguages.Text + newLine + languages; rng.InsertAfter(lbLanguages.Text); //EDUCATION string education = string.Empty; var lbEducation = new Label(); foreach (var vEduc in BulletedListEducation.Items) { education += " - " + vEduc + newLine; } lbEducation.Text = newLine + LabelEducation.Text + newLine + education; rng.InsertAfter(lbEducation.Text); //CERTIFICATES string certificate = string.Empty; var lbCertificate = new Label(); foreach (var vCert in BulletedListCertificates.Items) { certificate += " - " + vCert + newLine; } lbCertificate.Text = newLine + LabelCertificates.Text + newLine + certificate; rng.InsertAfter(lbCertificate.Text); //COURSES string course = string.Empty; var lbCourse = new Label(); foreach (var vCourse in BulletedListCourses.Items) { course += " - " + vCourse + newLine; } lbCourse.Text = newLine + LabelCourses.Text + newLine + course; rng.InsertAfter(lbCourse.Text); //PREV WORK string prevWork = string.Empty; var lbPrevWork = new Label(); foreach (var vPrevWork in BulletedListPrevWork.Items) { prevWork += " - " + vPrevWork + newLine; } lbPrevWork.Text = newLine + LabelPrevWork.Text + newLine + prevWork; rng.InsertAfter(lbPrevWork.Text); //BUS KNOW string busKnow = string.Empty; var lbBusKnow = new Label(); foreach (var vBusKnow in BulletedListBusKnow.Items) { busKnow += " - " + vBusKnow + newLine; } lbBusKnow.Text = newLine + LabelBusKnow.Text + newLine + busKnow; rng.InsertAfter(lbBusKnow.Text); rng.InsertBefore(newLine.ToString()); //TECHNICAL SKILLS //DATABASE string database = string.Empty; var lbDatabase = new Label(); foreach (var vDatabase in BulletedListDatabase.Items) { database += " - " + vDatabase + newLine; } lbDatabase.Text = newLine + LabelDatabase.Text + newLine + database; rng.InsertAfter(lbDatabase.Text); //PROGRAMMING string prog = string.Empty; var lbProg = new Label(); foreach (var vProg in BulletedListProgramming.Items) { prog += " - " + vProg + newLine; } lbProg.Text = newLine + LabelProgramming.Text + newLine + prog; rng.InsertAfter(lbProg.Text); //DEV TOOLS string devTool = string.Empty; var lbDevTool = new Label(); foreach (var vDevTool in BulletedListDevTools.Items) { devTool += " - " + vDevTool + newLine; } lbDevTool.Text = newLine + LabelDevTools.Text + newLine + devTool; rng.InsertAfter(lbDevTool.Text); //WEB SRV string webSrv = string.Empty; var lbWebSrv = new Label(); foreach (var vWebSrv in BulletedListWebSrv.Items) { webSrv += " - " + vWebSrv + newLine; } lbWebSrv.Text = newLine + LabelWebSrv.Text + newLine + webSrv; rng.InsertAfter(lbWebSrv.Text); //PROJECT METHODS string projMeth = string.Empty; var lbProjMeth = new Label(); foreach (var vProjMeth in BulletedListPrevWork.Items) { projMeth += " - " + vProjMeth + newLine; } lbProjMeth.Text = newLine + LabelProjMeth.Text + newLine + projMeth; rng.InsertAfter(lbProjMeth.Text); //ASSIGNMENTS if (RadioButtonListLanguage.SelectedItem.Text == "Swedish") { SetCustomizedCvAssignmentsSkillSweDoc(); //var border = new Image(); //border.ImageUrl = Request.Url.AbsoluteUri + "~/_layouts/images/Knowit.Cv/border.jpg"; Label upd = new Label(); upd.Text = newLine + "Uppdrag" + newLine; rng.InsertAfter(upd.Text); for (int i = 0; i < RepeaterAssignments.Controls.Count; i++) { var compName = (Label)RepeaterAssignments.FindControl("cn" + i); var sectName = (Label)RepeaterAssignments.FindControl("sn" + i); var areaName = (Label)RepeaterAssignments.FindControl("an" + i); var descSwe = (Label)RepeaterAssignments.FindControl("de" + i); var refName = (Label)RepeaterAssignments.FindControl("rn" + i); var toolName = (Label)RepeaterAssignments.FindControl("tn" + i); var techName = (Label)RepeaterAssignments.FindControl("ten" + i); var date = (Label)RepeaterAssignments.FindControl("ld" + i); var compNameLit = (Literal)RepeaterAssignments.FindControl("cnl" + i); var sectNameLit = (Literal)RepeaterAssignments.FindControl("sel" + i); var areaNameLit = (Literal)RepeaterAssignments.FindControl("anl" + i); var descSweLit = (Literal)RepeaterAssignments.FindControl("del" + i); var refNameLit = (Literal)RepeaterAssignments.FindControl("rnl" + i); var toolNameLit = (Literal)RepeaterAssignments.FindControl("tnl" + i); var techNameLit = (Literal)RepeaterAssignments.FindControl("tenl" + i); var dateLit = (Literal)RepeaterAssignments.FindControl("dl" + i); if (compName != null && sectName != null && areaName != null && descSwe != null && refName != null && toolName != null && techName != null && date != null && compNameLit != null && sectNameLit != null && areaNameLit != null && descSweLit != null && refNameLit != null && toolNameLit != null && techNameLit != null && dateLit != null) { rng.InsertAfter(newLine + compNameLit.Text + compName.Text + newLine); rng.InsertAfter(sectNameLit.Text + sectName.Text + newLine); rng.InsertAfter(areaNameLit.Text + areaName.Text + newLine); rng.InsertAfter(descSweLit.Text + descSwe.Text + newLine); rng.InsertAfter(refNameLit.Text + refName.Text + newLine); rng.InsertAfter(toolNameLit.Text + toolName.Text + newLine); rng.InsertAfter(techNameLit.Text + techName.Text + newLine); rng.InsertAfter(dateLit.Text + date.Text + newLine); } else { break; } //string borderUrl = border.ImageUrl; //rng.InlineShapes.AddPicture(borderUrl, ref missing, ref missing, ref missing); } } else if (RadioButtonListLanguage.SelectedItem.Text == "English") { SetCustomizedCvAssignmentsSkillEngDoc(); Label upd = new Label(); upd.Text = newLine + "Assignment" + newLine; rng.InsertAfter(upd.Text); for (int i = 0; i < RepeaterAssignments.Controls.Count; i++) { var compName = (Label)RepeaterAssignments.FindControl("cn" + i); var sectName = (Label)RepeaterAssignments.FindControl("sn" + i); var areaName = (Label)RepeaterAssignments.FindControl("an" + i); var descEng = (Label)RepeaterAssignments.FindControl("de" + i); var refName = (Label)RepeaterAssignments.FindControl("rn" + i); var toolName = (Label)RepeaterAssignments.FindControl("tn" + i); var techName = (Label)RepeaterAssignments.FindControl("ten" + i); var date = (Label)RepeaterAssignments.FindControl("ld" + i); var compNameLit = (Literal)RepeaterAssignments.FindControl("cnl" + i); var sectNameLit = (Literal)RepeaterAssignments.FindControl("sel" + i); var areaNameLit = (Literal)RepeaterAssignments.FindControl("anl" + i); var descEngLit = (Literal)RepeaterAssignments.FindControl("del" + i); var refNameLit = (Literal)RepeaterAssignments.FindControl("rnl" + i); var toolNameLit = (Literal)RepeaterAssignments.FindControl("tnl" + i); var techNameLit = (Literal)RepeaterAssignments.FindControl("tenl" + i); var dateLit = (Literal)RepeaterAssignments.FindControl("dl" + i); if (compName != null && sectName != null && areaName != null && descEng != null && refName != null && toolName != null && techName != null && date != null && compNameLit != null && sectNameLit != null && areaNameLit != null && descEngLit != null && refNameLit != null && toolNameLit != null && techNameLit != null && dateLit != null) { rng.InsertAfter(newLine + compNameLit.Text + compName.Text + newLine); rng.InsertAfter(sectNameLit.Text + sectName.Text + newLine); rng.InsertAfter(areaNameLit.Text + areaName.Text + newLine); rng.InsertAfter(descEngLit.Text + descEng.Text + newLine); rng.InsertAfter(refNameLit.Text + refName.Text + newLine); rng.InsertAfter(toolNameLit.Text + toolName.Text + newLine); rng.InsertAfter(techNameLit.Text + techName.Text + newLine); rng.InsertAfter(dateLit.Text + date.Text + newLine); } else { break; } } } } catch (Exception) { throw; } finally { myDoc.Save(); if (RadioButtonListLanguage.SelectedItem.Text == "Swedish") { RepeaterAssignments.Controls.Clear(); SetCustomizedCvAssignmentsSkillSwe(); } else if (RadioButtonListLanguage.SelectedItem.Text == "English") { RepeaterAssignments.Controls.Clear(); SetCustomizedCvAssignmentsSkillEng(); } } Response.ContentType = "Application/msword"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName); Response.TransmitFile(Server.MapPath("~/Upload/") + fileName); Response.End(); } } -------------- UPDATE------------------------ i Did like this with Pdf document and it works-------------- UPDATE------------------------i Did like this with Pdf document and it worksprivate void DownloadPdf() { string filename = CleanUp(LabelFirstNameFromDb.Text + "_" + LabelLastNameFromDb.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd") + "." + DropDownListDownload.SelectedItem.Text); //string filename = LabelFirstNameFromDb.Text + "_" + LabelLastNameFromDb.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd") + "." + DropDownListDownload.SelectedItem.Text; var db = new KnowItCvdbEntities(); SPWeb theSite = SPControl.GetContextWeb(Context); SPUser theUser = theSite.CurrentUser; string strUserName = theUser.LoginName; var theEmpl = (from p in db.EMPLOYEES where p.username == strUserName select p).FirstOrDefault(); if (theEmpl != null) { //Create Document class object and set its size to letter and give space left, right, Top, Bottom Margin var doc = new Document(PageSize.A4); try { PdfWriter.GetInstance(doc, new FileStream(Server.MapPath("~/Upload/") + filename, FileMode.Create)); var sv = new StringWriter(); doc.Open();//Open Document to write var hTextWriter = new HtmlTextWriter(sv); hTextWriter.WriteBeginTag("table border=1 cellpadding=25"); hTextWriter.Write(HtmlTextWriter.TagRightChar); hTextWriter.WriteBeginTag("tr"); hTextWriter.Write(HtmlTextWriter.TagRightChar); hTextWriter.WriteBeginTag("td"); hTextWriter.Write(HtmlTextWriter.TagRightChar); ImageProfPic.ImageUrl = theEmpl.image; ImageProfPic.RenderControl(hTextWriter); Label space = new Label(); space.Text = "<br/>"; space.RenderControl(hTextWriter); var name = new Label(); ImageKnowIt.ImageUrl = theEmpl.knowit_logo; ImageKnowIt.RenderControl(hTextWriter); name.Text = "<br/>" + LabelPosFromDb.Text + "" + " " + LabelFirstNameFromDb.Text + " " + LabelLastNameFromDb.Text + "<br/>" + LabelAboutFromDb.Text + "<br/>"; name.RenderControl(hTextWriter); SetCustomizedCvThreeTechSkill(); for (int i = 0; i < RepeaterStrongestSkill.Controls.Count; i++) { var skill = RepeaterStrongestSkill.FindControl("skill" + i); var pie = RepeaterStrongestSkill.FindControl("pie" + i); if (skill != null && pie != null) { pie.RenderControl(hTextWriter); skill.RenderControl(hTextWriter); } else { break; } } var background = new Label { Text = "<br/>" + LabelBackground.Text + "<br/>" + LabelDoB.Text + LabelDoBFromDb.Text + "<br/>" + LabelPhone.Text + LabelPhoneFromDb.Text + "<br/>" + LabelEmail.Text + LabelEmailFromDb.Text + "<br/>" + LabelPosition.Text + LabelPositionFromDb.Text + "<br/>" }; background.RenderControl(hTextWriter); //LANGUAGES string languages = string.Empty; var lbLanguages = new Label(); foreach (var vLang in BulletedListLanguages.Items) { languages += " - " + vLang + "<br/>"; } lbLanguages.Text = "<br/>" + LabelLanguages.Text + "<br/>" + languages + "<br/>"; lbLanguages.RenderControl(hTextWriter); //EDUCATION string educations = string.Empty; var lbEducation = new Label(); foreach (var vEduc in BulletedListEducation.Items) { educations += " - " + vEduc + "<br/>"; } lbEducation.Text = "" + LabelEducation.Text + "<br/>" + educations + "<br/>"; lbEducation.RenderControl(hTextWriter); //CERTIFICATES string certificates = string.Empty; var lbCertificate = new Label(); foreach (var vCert in BulletedListCertificates.Items) { certificates += " - " + vCert + "<br/>"; } lbCertificate.Text = "" + LabelCertificates.Text + "<br/>" + certificates + "<br/>"; lbCertificate.RenderControl(hTextWriter); //COURSES string courses = string.Empty; var lbCourse = new Label(); foreach (var vCourse in BulletedListCourses.Items) { courses += " - " + vCourse + "<br/>"; } lbCourse.Text = "" + LabelCourses.Text + "<br/>" + courses + "<br/>"; lbCourse.RenderControl(hTextWriter); //PREV WORK EXP string prevWork = string.Empty; var lbPrevWork = new Label(); foreach (var vPrevWork in BulletedListPrevWork.Items) { prevWork += " - " + vPrevWork + "<br/>"; } lbPrevWork.Text = "" + LabelPrevWork.Text + "<br/>" + prevWork + "<br/>"; lbPrevWork.RenderControl(hTextWriter); //BUS KNOW string busKnow = string.Empty; var lbBusKnow = new Label(); foreach (var vBusKnow in BulletedListBusKnow.Items) { busKnow += " - " + vBusKnow + "<br/>"; } lbBusKnow.Text = "" + LabelBusKnow.Text + "<br/>" + busKnow + "<br/>"; lbBusKnow.RenderControl(hTextWriter); //DATABASE SKILL string database = string.Empty; var lbDatabase = new Label(); foreach (var vDatabase in BulletedListDatabase.Items) { database += " - " + vDatabase + "<br/>"; } lbDatabase.Text = "<br/>" + LabelDatabase.Text + "<br/>" + database + "<br/>"; lbDatabase.RenderControl(hTextWriter); //PROGRAMMING SKILL string prog = string.Empty; var lbProg = new Label(); foreach (var vProg in BulletedListProgramming.Items) { prog += " - " + vProg + "<br/>"; } lbProg.Text = "" + LabelProgramming.Text + "<br/>" + prog + "<br/>"; lbProg.RenderControl(hTextWriter); //DEV TOOL SKILL string devTool = string.Empty; var lbDevTool = new Label(); foreach (var vDevTool in BulletedListDevTools.Items) { devTool += " - " + vDevTool + "<br/>"; } lbDevTool.Text = "" + LabelDevTools.Text + "<br/>" + devTool + "<br/>"; lbDevTool.RenderControl(hTextWriter); //WEB SRV SKILL string webSrv = string.Empty; var lbWebSrv = new Label(); foreach (var vWebSrv in BulletedListWebSrv.Items) { webSrv += " - " + vWebSrv + "<br/>"; } lbWebSrv.Text = "" + LabelWebSrv.Text + "<br/>" + webSrv + "<br/>"; lbWebSrv.RenderControl(hTextWriter); //PROJECT METHOD SKILL string projMeth = string.Empty; var lbProjMeth = new Label(); foreach (var vProjMeth in BulletedListProjMeth.Items) { projMeth += " - " + vProjMeth + "<br/>"; } lbProjMeth.Text = "" + LabelProjMeth.Text + "<br/>" + projMeth + "<br/>"; lbProjMeth.RenderControl(hTextWriter); hTextWriter.WriteEndTag("td"); hTextWriter.WriteEndTag("tr"); hTextWriter.WriteEndTag("table"); space.RenderControl(hTextWriter); hTextWriter.WriteBeginTag("table border=1 cellpadding=25"); hTextWriter.Write(HtmlTextWriter.TagRightChar); hTextWriter.WriteBeginTag("tr"); hTextWriter.Write(HtmlTextWriter.TagRightChar); hTextWriter.WriteBeginTag("td"); hTextWriter.Write(HtmlTextWriter.TagRightChar); //ASSIGNMENTS if (RadioButtonListLanguage.SelectedItem.Text == "Swedish") { SetCustomizedCvAssignmentsSkillSwe(); Label upd = new Label(); upd.Text = "<br/>" + "Uppdrag" + "</br><br/>"; upd.RenderControl(hTextWriter); for (int i = 0; i < RepeaterAssignments.Controls.Count; i++) { var compName = RepeaterAssignments.FindControl("cn" + i); var sectName = RepeaterAssignments.FindControl("sn" + i); var areaName = RepeaterAssignments.FindControl("an" + i); var descSwe = RepeaterAssignments.FindControl("de" + i); var refName = RepeaterAssignments.FindControl("rn" + i); var toolName = RepeaterAssignments.FindControl("tn" + i); var techName = RepeaterAssignments.FindControl("ten" + i); var date = RepeaterAssignments.FindControl("ld" + i); var compNameLit = RepeaterAssignments.FindControl("cnl" + i); var sectNameLit = RepeaterAssignments.FindControl("sel" + i); var areaNameLit = RepeaterAssignments.FindControl("anl" + i); var descSweLit = RepeaterAssignments.FindControl("del" + i); var refNameLit = RepeaterAssignments.FindControl("rnl" + i); var toolNameLit = RepeaterAssignments.FindControl("tnl" + i); var techNameLit = RepeaterAssignments.FindControl("tenl" + i); var dateLit = RepeaterAssignments.FindControl("dl" + i); var spaceLit = RepeaterAssignments.FindControl("spl" + i); if (compName != null && sectName != null && areaName != null && descSwe != null && refName != null && toolName != null && techName != null && date != null && compNameLit != null && sectNameLit != null && areaNameLit != null && descSweLit != null && refNameLit != null && toolNameLit != null && techNameLit != null && dateLit != null) { compNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); compName.RenderControl(hTextWriter); sectNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); sectName.RenderControl(hTextWriter); areaNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); areaName.RenderControl(hTextWriter); descSweLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); descSwe.RenderControl(hTextWriter); refNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); refName.RenderControl(hTextWriter); toolNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); toolName.RenderControl(hTextWriter); techNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); techName.RenderControl(hTextWriter); dateLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); date.RenderControl(hTextWriter); var border = new Image(); border.ImageUrl = Request.Url.AbsoluteUri + "~/_layouts/images/Knowit.Cv/border.jpg"; border.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); } else { break; } } } else if (RadioButtonListLanguage.SelectedItem.Text == "English") { SetCustomizedCvAssignmentsSkillEng(); Label upd = new Label(); upd.Text = "<br/>" + "Assignment" + "</br><br/>"; upd.RenderControl(hTextWriter); for (int i = 0; i < RepeaterAssignments.Controls.Count; i++) { var compName = RepeaterAssignments.FindControl("cn" + i); var sectName = RepeaterAssignments.FindControl("sn" + i); var areaName = RepeaterAssignments.FindControl("an" + i); var descEng = RepeaterAssignments.FindControl("de" + i); var refName = RepeaterAssignments.FindControl("rn" + i); var toolName = RepeaterAssignments.FindControl("tn" + i); var techName = RepeaterAssignments.FindControl("ten" + i); var date = RepeaterAssignments.FindControl("ld" + i); var compNameLit = RepeaterAssignments.FindControl("cnl" + i); var sectNameLit = RepeaterAssignments.FindControl("sel" + i); var areaNameLit = RepeaterAssignments.FindControl("anl" + i); var descEngLit = RepeaterAssignments.FindControl("del" + i); var refNameLit = RepeaterAssignments.FindControl("rnl" + i); var toolNameLit = RepeaterAssignments.FindControl("tnl" + i); var techNameLit = RepeaterAssignments.FindControl("tenl" + i); var dateLit = RepeaterAssignments.FindControl("dl" + i); var spaceLit = RepeaterAssignments.FindControl("spl" + i); if (compName != null && sectName != null && areaName != null && descEng != null && refName != null && toolName != null && techName != null && date != null && compNameLit != null && sectNameLit != null && areaNameLit != null && descEngLit != null && refNameLit != null && toolNameLit != null && techNameLit != null && dateLit != null) { compNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); compName.RenderControl(hTextWriter); sectNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); sectName.RenderControl(hTextWriter); areaNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); areaName.RenderControl(hTextWriter); descEngLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); descEng.RenderControl(hTextWriter); refNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); refName.RenderControl(hTextWriter); toolNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); toolName.RenderControl(hTextWriter); techNameLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); techName.RenderControl(hTextWriter); dateLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); date.RenderControl(hTextWriter); var border = new Image(); border.ImageUrl = Request.Url.AbsoluteUri + "~/_layouts/images/Knowit.Cv/border.jpg"; border.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); spaceLit.RenderControl(hTextWriter); } else { break; } } } hTextWriter.WriteEndTag("td"); hTextWriter.WriteEndTag("tr"); hTextWriter.WriteEndTag("table"); String strHtml1 = sv.ToString(); var hw = new HTMLWorker(doc); hw.Parse(new StringReader(strHtml1)); } finally { doc.Close(); } //Download to stream Response.ContentType = "Application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename); Response.TransmitFile(Server.MapPath("~/Upload/") + filename); Response.End(); } }推荐答案I think it is an issue on the MS Word COM Object. By default the ASPNET user, under which your site is probably running, does not have permissions to access the COM. The link below should give you a good idea where it is located and which users you need to grant access to. MS Word COM[^] On a side note, you do know that MS Word automation on a server is not recommended by MS. It is a risky business. The last time I did this kind of thing, I did it like below. No need for messing around with COM or permissions. Create Word document[^]I think it is an issue on the MS Word COM Object. By default the ASPNET user, under which your site is probably running, does not have permissions to access the COM. The link below should give you a good idea where it is located and which users you need to grant access to.MS Word COM[^]On a side note, you do know that MS Word automation on a server is not recommended by MS. It is a risky business. The last time I did this kind of thing, I did it like below. No need for messing around with COM or permissions.Create Word document[^]IIS application pool does not have write permissions to the folder Upload. You have to grant the IIS Applicationpool user write permissions to that folder in order to to this. What IIS version are you using?IIS application pool does not have write permissions to the folder Upload. You have to grant the IIS Applicationpool user write permissions to that folder in order to to this.What IIS version are you using? 这篇关于Word文档不会保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 08:47