請告訴我如何將當前頁面保存爲按鈕單擊時的html頁面。我的頁面只包含我在頁面加載事件中填寫的標籤。我在下面的代碼中使用了這個代碼,但它並沒有保存(在HTML中)當我的頁面被加載(我認爲它在頁面上加載值之前轉換)時看到的所有值。如何將當前的aspx頁面保存爲html
private void saveCurrentAspxToHTML()
{
string HTMLfile = "http://localhost:4997/MEA5/AEPRINT.aspx?id=" +
Convert.ToString(frmae.AeEventid) +
"&eid=" +
Convert.ToString(frmae.AeEnquiryid);
WebRequest myRequest = WebRequest.Create(HTMLfile);
// Return the response.
WebResponse myResponse = myRequest.GetResponse();
// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(ReceiveStream, encode);
// Read 256 charcters at a time.
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
using (StreamWriter sw = new StreamWriter(Server.MapPath("~") + "\\MyPage.htm"))
{
while (count > 0)
{
// Dump the 256 characters on a string and display the string onto the console.
String str = new String(read, 0, count);
sw.Write(str);
count = readStream.Read(read, 0, 256);
}
}
// Close the response to free resources.
myResponse.Close();
}
請幫幫我!
請問您可以給一些演示或文檔? – 2016-01-01 10:04:50