求asp.net生成静态页面的源码下载地址
我邮箱是[email protected]

解决方案 »

  1.   

    /// <summary>
    /// 生成HTML页
    /// </summary>
    /// <param name="strText">新闻名称</param>
    /// <param name="strContent">新闻内容</param>
    /// <param name="strTime">发表时间</param>
    /// <returns></returns>
    public  bool WriteFile(string strText,string strTime,string strContent)
    {
    string path = HttpContext.Current.Server.MapPath("news/");
    Encoding code = Encoding.GetEncoding("gb2312");
    // 读取模板文件
    string temp = HttpContext.Current.Server.MapPath("news/test.htm");
    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("TitleTitle",strText); //模板页中的ShowArticle
    str = str.Replace("TimesTimes",strTime);
    str = str.Replace("MemoMemo",strContent);
    // 写文件
    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;  }
      

  2.   

    其实它的思路很简单,就是先做一个模板TEST.HTM,把新闻页面的样式先做进去,然后把它读取到一个变量中,把里面的新闻标题,内容等到替换掉,然后再写入一个文件.
      

  3.   

    test.htm
    ___________________________________________________________________________<table cellspacing="0" cellpadding="0" width="537" border="0">
      <tbody>
        <tr> 
          <td width="511"> <table cellspacing="0" cellpadding="0" width="100%" border="0">
              <tbody>
                <tr> 
                  <td width="30">&nbsp;</td>
                  <td align="center" class="a1"><font color="#cc0000" size="3"><strong> 
                    <span id="News_Title">TitleTitle</span></strong></font></td>
                </tr>
              </tbody>
            </table></td>
        </tr>
        <tr> 
          <td height="30"> <table cellspacing="0" cellpadding="0" width="100%" border="0">
              <tbody>
                <tr class="a3"> 
                  <td align="right"> <span id="News_Time">发表日期:TimesTimes</span> &nbsp;&nbsp;&nbsp;</td>
                </tr>
              </tbody>
            </table></td>
        </tr>
        <tr> 
          <td valign="top" align="center"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" id="dstTable">
              <tbody>
                <tr> 
                  <td width="100%" class="a2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MemoMemo</td>
                </tr>
              </tbody>
            </table></td>
        </tr>
      </tbody>
    </table>
      

  4.   

    http://community.csdn.net/Expert/topic/4676/4676923.xml?temp=9.559268E-02
      

  5.   

    生成单个html不难,但如果大量生成html问题就出来了。生成后如何链接问题就出来了
    不可能一个一个页面手动生成html,然后连接过去的吗?这样的话工作量岂不是巨大啊
    如何能够实现循环生成动态链接
    能提供一下源码的项目文件吗
    [email protected]
      

  6.   

    参考一下!!!
    有的话麻烦多发一封.谢谢
    [email protected]
      

  7.   

    我觉得应该直接修改用于缓存的http module