当前位置:编程学习 > C#/ASP.NET >>

如何生成静态页面

如何把http://www.ghmed.net/url.html这个页面生成一个静态的页面,而且相同的地区显示在同一行 --------------------编程问答-------------------- --------------------编程问答-------------------- 伪静态 还是生成静态页?
http://blog.csdn.net/fengyarongaa/article/details/6547796

http://blog.csdn.net/fengyarongaa/article/details/6541852
--------------------编程问答-------------------- 网上的例子多的是:http://zzk.cnblogs.com/s?w=%E7%94%9F%E6%88%90%E9%9D%99%E6%80%81%E9%A1%B5 --------------------编程问答-------------------- 静态页面 --------------------编程问答-------------------- 网上搜一大把,其实就3种方法实现
1、模板生成
2、直接c#代码
3、伪静态 --------------------编程问答-------------------- LZ这个页面貌似是静态的啊…… --------------------编程问答-------------------- 这个纯手写代码的静态页面,现在我做了后台管理的,可添加、删除,现在关键问题是生成静态页面后怎样让这些网址有规则的排序(例如:重庆市的要在同一行并且属于某一类型的要在同一列上)
想了一天都没想出来,急!! --------------------编程问答--------------------
引用 5 楼 zcxverygood123456 的回复:
网上搜一大把,其实就3种方法实现
1、模板生成
2、直接c#代码
3、伪静态

其它就二种

一个模板代替,一个是生成后保存 --------------------编程问答-------------------- 过段时间也得做这个 --------------------编程问答--------------------
学习了 --------------------编程问答-------------------- //使用模板生成HTML页 
    public static bool WriteFile(string strText, string strContent, string strAuthor)
    {
        string path = HttpContext.Current.Server.MapPath("~/news/");
        Encoding code = Encoding.GetEncoding("gb2312");
        // 读取模板文件 
        string temp = HttpContext.Current.Server.MapPath("~/news/text.html");
        StreamReader sr = null;
        StreamWriter sw = null;
        string str = "";
        try
        {
            sr = new StreamReader(temp, code);
            str = sr.ReadToEnd(); // 读取文件 
        }
        catch (Exception exp)
        {
            HttpContext.Current.Response.Write(exp.Message);
            HttpContext.Current.Response.End();
            sr.Close();
        }


        string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
        // 替换内容 
        // 这时,模板文件已经读入到名称为str的变量中了 
        str = str.Replace("ShowArticle", strText); //模板页中的ShowArticle 
        str = str.Replace("biaoti", strText);
        str = str.Replace("content", strContent);
        str = str.Replace("author", strAuthor);
        // 写文件 
        try
        {
            sw = new StreamWriter(path + htmlfilename, false, code);
            sw.Write(str);
            sw.Flush();
        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message);
            HttpContext.Current.Response.End();
        }
        finally
        {
            sw.Close();
        }
        return true;
    }
--------------------编程问答--------------------
引用 11 楼 feng_dongmei_123 的回复:
//使用模板生成HTML页 
  public static bool WriteFile(string strText, string strContent, string strAuthor)
  {
  string path = HttpContext.Current.Server.MapPath("~/news/");
  Encoding code = Encoding.Get……

这样替换了内容 然后 有链接的地方 怎么做呢。有点懵了  今天不在状态啊 --------------------编程问答-------------------- 老生常谈的问题了! --------------------编程问答-------------------- 伪静态挺简单的。。。 --------------------编程问答-------------------- 这个是用模板技术,freemark和velocity --------------------编程问答-------------------- 最简单的实现源码:
UrlRewrite实现伪静态 
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,