利用Render方法生成静态页
2008-01-28 16:46
483 查看
.net生成静态页的方法有好多种,在实验了n次后,终于找到了一种本人认为最简单最有效的方法,就是利用重写Render方法生成静态页.Render是在运用Html创建给浏览器输出的页面的时候发生的.很简单的一段代码就实现了静态页生成:
System.IO.StringWriter html = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(html);
base.Render(tw);
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("index.html"), false, System.Text.Encoding.Default);
sw.Write(html.ToString());
sw.Close();
tw.Close();
Response.Redirect("index.html");
将页面的html传送给生成的新页index.html,就行了.
System.IO.StringWriter html = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(html);
base.Render(tw);
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("index.html"), false, System.Text.Encoding.Default);
sw.Write(html.ToString());
sw.Close();
tw.Close();
Response.Redirect("index.html");
将页面的html传送给生成的新页index.html,就行了.
相关文章推荐
- Render方法生成静态页
- ASP.NET 动态页面生成静态页的方法
- 利用SQL存储过程生成程序编号的一种方法
- 利用eclipse(MyEclipse)快速生成set、get方法的方法
- asp.net生成静态页的两种方法
- 利用SQL存储过程生成程序编号的一种方法
- Asp.net_关于如何利用编译器把[.cs]文件生成动态链接库[.dll]文件方法的总结
- 【转载】利用smarty生成静态页详解
- JavaScript中利用doucument.writeline()方法预生成代码的小技巧
- asp.net生成静态页的方法
- 利用SQL存储过程生成程序编号的一种方法
- 如何利用Xcode自带的方法生成二维码
- 最简单的生成静态页方法
- ThinkPHP生成静态页buildHtml方法
- Qemu中生成针对具体体系结构的纯净代码的方法---利用GCC的-E选项
- C#利用定时任务插件实现在后台线程中批量把动态文件生成静态文件方法
- 利用Math.Random()方法来生成随机数。(转)
- 详谈asp生成静态页方法
- 详谈asp生成静态页方法
- Asp.net 2.0 中将网站首页生成静态页的一个比较好的方法