WebForm Server.Transfer-下载的文件中没有记录变量



我使用的是Server.Transfer,在第二个位置,我有许多用Request.Form["textbox_text"]更新的标签;

这一切都很好,但问题是我也想把文本框中的内容写入文件像使用这种方法的word文档

Response.Clear();
Response.AddHeader("Content-disposition", "attachment; filename=Word.doc");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application / vnd.ms -word";
Response.ContentEncoding = System.Text.Encoding.Unicode;
Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
htw.Write("<table><h2><b>[ Text ]</b></h2><br>" + TextBox_name.Text + "</table>");
Response.Write(sw.ToString());
Response.End();

但每当我检查文件时,上面都不会写任何内容。我甚至试图将Request.Form的值保存到一个静态变量中,然后写那个变量,但没有成功。

如何使用Server.Transfer()?张贴该代码,确保您使用的是保留表单值的重载:

Server.Transfer("page.aspx", true);

最新更新