zoukankan      html  css  js  c++  java
  • .net 动态页面生成静态页面


    .net 动态页面生成静态页面的方法大体可以分为三种

    1.url重写,只是链接地址换了(伪静态)

      <1> 在bin中添加引用

            URLRewriter.pdb
            URLRewriter.dll

      <2> 在web.config中的配置

             添加<system.web>                 

                       <httpModules>
                           <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>

                      </httpModules>

              </system.web>

             

        <configSections>
           <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/> 

        </configSections>

    <RewriterConfig>
            <Rules>
                <RewriterRule>
                    <LookFor>~/index\.html</LookFor><!--要显示的文件名称-->
                    <SendTo>~/index.aspx</SendTo><!--要替换的文件名称-->
                </RewriterRule>
            
            </Rules>
        </RewriterConfig>
     

             


    2.使用模板生成静态页面

    3.动态页面直接生成静态页面

    //url:动态页面的地址

    //savefile:要生成的晶体页面的地址

     private void ToHTML(string url,string savefile)
         {
             WebClient wc = new WebClient();
             byte[] bs = wc.DownloadData(url);
             string html = Encoding.GetEncoding("utf-8").GetString(bs);        
             string saveFile = Server.MapPath(savefile);
             StreamWriter sw = new StreamWriter(saveFile, false, Encoding.GetEncoding("utf-8"));
             sw.Write(html);
             sw.Close();
             Response.Write("恭喜,页面已经生成");
        }

  • 相关阅读:
    NFC Basics(基本NFC)——翻译自developer.android.com
    【LeetCode】Sort Colors 解题报告
    发送手机物理标识请求
    Java编程介绍
    emacs 中使用git diff命令行
    OpenJudge百炼习题解答(C++)--题4074:积水量
    编程之美2.9 斐波那契数列
    Application Architecture Determines Application Performance
    程序包javax.servlet.annotation不存在
    mysql 严格模式 Strict Mode说明
  • 原文地址:https://www.cnblogs.com/feifei/p/2133401.html
Copyright © 2011-2022 走看看