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.     }
  • 相关阅读:
    pip安装指定版本的package
    学习 git基础命令
    美剧命名规则
    Mac OS X中bogon的处理
    学习Maven之Maven Clean Plugin
    学习Maven之Cobertura Maven Plugin
    博客园markdown代码块支持的语言
    学习Maven之Maven Surefire Plugin(JUnit篇)
    C# Invoke或者BeginInvoke的使用
    LINQ to SQL语句(20)之存储过程
  • 原文地址:https://www.cnblogs.com/dingdingmao/p/3146593.html
Copyright © 2011-2022 走看看