C#生成單頁靜態(tài)頁簡單實例
更新時間:2014年10月10日 09:36:04 投稿:shichen2014
這篇文章主要介紹了C#生成單頁靜態(tài)頁簡單實例,是一個非常實用的技巧,需要的朋友可以參考下
本文實例講述了C#生成單頁靜態(tài)頁簡單實現(xiàn)方法。分享給大家供大家參考。具體方法如下:
復制代碼 代碼如下:
protected void BtGroup_ServerClick(object sender, EventArgs e)
{
//產(chǎn)業(yè)群首頁
string tempGroupData = GetHttpData(" 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;
}
{
//產(chǎn)業(yè)群首頁
string tempGroupData = GetHttpData(" 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#程序設計有所幫助。
相關文章
C#如何提取經(jīng)緯度文件中的經(jīng)緯度數(shù)據(jù)
近期開發(fā)時需要獲取當前的經(jīng)緯度坐標,下面這篇文章主要給大家介紹了關于C#如何提取經(jīng)緯度文件中經(jīng)緯度數(shù)據(jù)的相關資料,文中通過圖文介紹的非常詳細,需要的朋友可以參考下2022-08-08