1.
StreamWriter在你的aspx页面执行之后(也就是说先执行aspx.cs渲染后的aspx页面)形成的html代码然后再读取也就是 A.aspx => 后台对应的cs代码Render后 => A.aspx的页面内容
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("path.html"),false,System.Text.Encoding.GetEncoding("GB2312")); System.Web.HttpContext.Current.Server.Execute("t.aspx", sw);sw.Close();
2.这种最常用
WebRequest request = WebRequest.Create(path); WebResponse response = request.GetResponse(); Stream resStream = response.GetResponseStream(); StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default); string ContentHtml = sr.ReadToEnd();
3.见资料的写法 http://blog.csdn.net/zhanglei5415/article/details/1622165
protected override void Render(HtmlTextWriter writer){ System.IO.StringWriter html = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter tw = new System.Web.UI.HtmlTextWriter(html); base.Render(tw); System.IO.StreamWriter sw; sw = new System.IO.StreamWriter(Server.MapPath("静态页2.htm"), false, System.Text.Encoding.Default); sw.Write(html.ToString()); sw.Close(); tw.Close(); Response.Write(html.ToString()); }
时间: 2024-10-08 10:09:09