RSS
热门关键字:  ASP.NET  ASP  ASP.NET文件  html  ASP.NET 漫
当前位置 :| hh85>开发代码>asp.net>

ASP.NET(C#)根据URL地址静态生成

来源: 作者: 时间:2008-02-29 点击:
根据URL地址静态生成html页面


基本思想:
先从动态页面中读取出信息,在写入一个静态页面!
命名空间:
using System.Text;
using System.Net;
using System.IO;


关键代码:
String htmltext=string.Empty ;
try
{
WebRequest myRequest = WebRequest.Create("http://localhost:1602/theml/Default.aspx");
WebResponse myResponse=myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream());
//获取远程路径
htmltext = sr.ReadToEnd().ToString();
//读取
sr.Close();
}
catch (Exception ex)
{
Response.Write("<script>alert('出错了!')</script>");
}
try
{
StreamWriter sw = new StreamWriter(Server.MapPath("/test.html"), false, System.Text.Encoding.GetEncoding("GB2312"));
sw.Write(htmltext);
sw.Flush();
//写入
sw.Close();
}
catch (Exception ee)
{
Response.Write("<script>alert('出错了!')</script>");
}
TAG :
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表