zoukankan      html  css  js  c++  java
  • 做这个方法的时候,主要想到是的生成静态页面。

    1. /// <summary>
    2.     /// 从网上读取内容,在本地生成文件(静态页面生成)
    3.     /// </summary>
    4.     /// <param name="theaspxURL">要读取的地址</param>
    5.     /// <param name="theHtmlURL">生成页面的名称</param>
    6.     private void getContentToHtml(string theaspxURL,string theHtmlURL) 
    7.     {
    8.         HttpWebRequest hwq = (HttpWebRequest)WebRequest.Create(theaspxURL);//
    9.         hwq.Method = "GET";//请求方式
    10.         hwq.ContentType = "application/x-www-form-urlencoded;charset=utf8";//标头文件
    11.         WebResponse hwr = (WebResponse)hwq.GetResponse();//得到相应的资源
    12.         byte[] bytes = new byte[hwr.ContentLength];//实例化二进制流
    13.         Stream stream = hwr.GetResponseStream();//返回数据流
    14.         //Response.Write(hwr.ContentLength.ToString() + "<br/>");
    15.         //Response.Write(hwq.ContentLength.ToString());
    16.         stream.Read(bytes, 0, Convert.ToInt32(hwr.ContentLength));//读取信息 放到位二进制流里面
    17.         //HttpContext.Current.Response.BinaryWrite(bytes);//页面输出显示
    18.         string filePath = theHtmlURL;    //文件地址
    19.         filePath = Server.MapPath(filePath);//得到绝对路径
    20.         File.WriteAllBytes(filePath, bytes);//输出内容
    21.     }
  • 相关阅读:
    前端规范标准(一)
    node之旅(3) Express之我的第一个应用
    node之旅(2) hello wrold!
    node之旅(1) 安装NodeJS
    CSS3 基础知识
    博客转移公告
    博客主题更换留念
    网络流-费用流zkw算法
    网络流-最大流ISAP
    字符串总结-三大“自动机”
  • 原文地址:https://www.cnblogs.com/dingdingmao/p/3146593.html
Copyright © 2011-2022 走看看