您的位置:首页 > 编程语言 > C#

简单的单页c#生成静态页源码

2009-03-21 15:22 309 查看
protected void BtGroup_ServerClick(object sender, EventArgs e)
{
//产业群首页
string tempGroupData = GetHttpData("http://www.goudiannao.com/Group/index.aspx");
using (StreamWriter sw = new StreamWriter(this.Request.PhysicalApplicationPath + "Group\\Index.html", false, System.Text.Encoding.GetEncoding("utf-8")))
{
sw.Write(tempGroupData);
sw.Flush();
}

}
public string GetHttpData(string sUrl)
{
string sRslt = null;
WebResponse oWebRps = null;
WebRequest oWebRqst = WebRequest.Create(sUrl);
oWebRqst.Timeout = 50000;
try
{
oWebRps = oWebRqst.GetResponse();
}

finally
{
if (oWebRps != null)
{
StreamReader oStreamRd = new StreamReader(oWebRps.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
sRslt = oStreamRd.ReadToEnd();
oStreamRd.Close();
oWebRps.Close();
}
}
return sRslt;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: