积极答复者
根据ASPX网页中输入的内容,生成静态的HTML页面?

问题
答案
-
你好
思想就是,向客户端发送 html 标记,并且在 http 请求头部告诉客户端,你发送的是一个静态页面,如 “text/html”,那么客户端就能正确识别。你可以用respose——响应——来实现,等等。如果你用 JavaScript 框架,实现起来会更简单。
1+1=The World >>> BLOG=http://blog.csdn.net/liuning800203 >>> Email=liuning800203@hotmail.com- 已编辑 0_1_TheWorld 2011年10月16日 15:35 补充
- 已标记为答案 hu_772000 2012年3月5日 8:45
全部回复
-
可以用WebClient或WebRequest去取得Html Code后
在网站下生成Html档案
如下(WebClient):
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.OleDb; using System.Data.Common; using System.Data.Objects; using System.Linq.Expressions; using System.Net; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebClient wc = new WebClient(); wc.Encoding = System.Text.Encoding.UTF8; string html = wc.DownloadString("http://localhost:4815/test/Default5.aspx"); System.IO.FileStream fs=new System.IO.FileStream(Server.MapPath("~/test.html"),System.IO.FileMode.Create); StreamWriter sw=new StreamWriter(fs); sw.Write(html); sw.Close(); fs.Close(); } } }
WebRequest的Sample Code
Shadowと愉快なコード達
- 已编辑 Shadow .Net 2011年10月13日 13:49
- 已标记为答案 Song TianModerator 2011年10月19日 8:55
- 取消答案标记 gsralexModerator 2011年10月20日 9:01
-
你好
思想就是,向客户端发送 html 标记,并且在 http 请求头部告诉客户端,你发送的是一个静态页面,如 “text/html”,那么客户端就能正确识别。你可以用respose——响应——来实现,等等。如果你用 JavaScript 框架,实现起来会更简单。
1+1=The World >>> BLOG=http://blog.csdn.net/liuning800203 >>> Email=liuning800203@hotmail.com- 已编辑 0_1_TheWorld 2011年10月16日 15:35 补充
- 已标记为答案 hu_772000 2012年3月5日 8:45
-
HttpContext.Current.Server.Execute(Page,StringWriter)
本身的fcl库提供的方法就可以,不需要再用webclient下载下来,虽然也可以,不过有点怪异~
- 已建议为答案 gsralexModerator 2011年10月25日 5:37