C#生成單頁靜態頁簡略實例。本站提示廣大學習愛好者:(C#生成單頁靜態頁簡略實例)文章只能為提供參考,不一定能成為您想要的結果。以下是C#生成單頁靜態頁簡略實例正文
本文實例講述了C#生成單頁靜態頁簡略完成辦法。分享給年夜家供年夜家參考。詳細辦法以下:
protected void BtGroup_ServerClick(object sender, EventArgs e)
{
//家當群首頁
string tempGroupData = GetHttpData("http://www.XXXX.com/Test/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;
}
願望本文所述對年夜家的C#法式設計有所贊助。