protected
void
Button1_Click(
object
sender, EventArgs e)
... {
string lcUrl = "http://localhost:2344/Web/index.aspx";
HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(lcUrl);
// *** Set properties
loHttp.Timeout = 10000; // 10 secs
// loHttp.UserAgent = "Code Sample Web Client";
// *** Retrieve request info headers
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = Encoding.GetEncoding("UTF-8"); // Windows default Code Page
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
Response.Write(lcHtml);
//
string path = "E:/lauka/NewSkyhu/Web/index.html";
Create_html(path, lcHtml);
}
private void Create_html( string allfilename, string htmlcode)
... {
FileStream CreateFile = new FileStream(allfilename, FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(CreateFile);
sw.WriteLine(htmlcode);//将拼好的Html代码写入页面中
sw.Close();
}
... {
string lcUrl = "http://localhost:2344/Web/index.aspx";
HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(lcUrl);
// *** Set properties
loHttp.Timeout = 10000; // 10 secs
// loHttp.UserAgent = "Code Sample Web Client";
// *** Retrieve request info headers
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = Encoding.GetEncoding("UTF-8"); // Windows default Code Page
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
Response.Write(lcHtml);
//
string path = "E:/lauka/NewSkyhu/Web/index.html";
Create_html(path, lcHtml);
}
private void Create_html( string allfilename, string htmlcode)
... {
FileStream CreateFile = new FileStream(allfilename, FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(CreateFile);
sw.WriteLine(htmlcode);//将拼好的Html代码写入页面中
sw.Close();
}