首页 > Web开发 > 详细

ASP.NET静态化方法

时间:2014-03-08 07:22:02      阅读:514      评论:0      收藏:0      [点我收藏+]

突然想到一个静态化页面的方法:直接保存源代码即可。

模拟浏览器访问,获得源码,写入文件。不知道是否存在安全风险;各位大神请指点:

bubuko.com,布布扣
        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");
bubuko.com,布布扣

ASP.NET静态化方法,布布扣,bubuko.com

ASP.NET静态化方法

原文:http://www.cnblogs.com/shya/p/3586417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!