日期:2014-05-18  浏览次数:20535 次

关于asp.net静态生成
在做asp.net静态生成的时候用什么静态生成的方法比较好?
比较方便的是用webclient类的downloadfile来做,不过好象用这个方法的人不是很多,不知道为什么.效率问题吗?
还有一个常用的方法是做一个模板然后字符串替换.
这两种方法哪一个比较好?
还有在用模板的时候可不可以做的和zblog那样的自定义,比如说在模板里面写这样的:
#文章列表(类别1,显示的数量,显示的内容)#
#articleList(10,10,'title,author,pubtime')#

用这样的模板根据模板里面的参数做生成相应的静态页面应该如何做呢?

------解决方案--------------------
使用模板页,可以单独建一个项目,项目中编写模板页中用到的函数,创建一个虚拟目录 指向存放模板页的文件夹,然后将模板页中调用函数所属的项目的bin文件复制到存放模板页的文件夹中,这样就可以通过虚拟路径访问模板页,获取页面新闻,然后在后台中,通过读取模板页的内容,生成静态页了。

HTML code
<%@ Page language="c#" AutoEventWireup="false" Inherits="wr.news2" %><html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>相关链接东营市中级人民法院“东营经验”专题</title>
<link href="index.css" rel="stylesheet" type="text/css">
<base target="_blank">
</head>

<body>
<table width="770" height="241" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="250" height="128" valign="top"><table width="240" height="30" border="0" cellpadding="0" cellspacing="0" style="border:#A1A1A1 1px solid">
      <tr>
        <td width="238" height="30" background="images/bg2.jpg">&nbsp;</td>
      </tr>
    </table></td>
    <td width="520" valign="top"><table width="520" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="29" background="images/news4.jpg"><table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="433" class="lanmu">相关链接</td>
            <td width="67" class="img-title"><strong><a href="default.htm"><font color="#CC0000">返回首页</font></a></strong></td>
          </tr>
        </table></td>
      </tr>

    </table>
      <table width="520" height="598" border="0" cellpadding="0" cellspacing="0" style="border:#990000 1px solid">
        <tr>
          <td height="595" valign="top"><table width="500" height="14" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td height="14">&nbsp;</td>
            </tr>
          </table><br>
         <table width="500" height="14" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td class="TextList4" valign="top"><%=GetPageNews("xglj",null,537,1,Request["PageNum"],18)%></td>
            </tr>
          </table>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="10"></td>
  </tr>
</table>
</body>
</html>

------解决方案--------------------
建议用 XML+XSLT + HttpHandler 生成静态文件!
------解决方案--------