突然想到一个静态化页面的方法:直接保存源代码即可。
模拟浏览器访问,获得源码,写入文件。不知道是否存在安全风险;各位大神请指点:
string file = Server.MapPath("/") + "index.html"; Response.Write(file); //Response.End(); //return; WebClient web = new WebClient(); byte[] buffer = web.DownloadData("http://localhost:81/"); string result = Encoding.UTF8.GetString(buffer); FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8); sw.Write(result); sw.Flush(); sw.Close(); fs.Close(); Response.Redirect("http://localhost:81/index.html");