SEO之网站权威度优化asp.net中使用md5加密

asp.net生成html静态页

2008年1月4日 12:59:48 admin ASP.NET

cs文件

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
/// <summary>
/// create_page 的摘要说明
/// </summary>
public class create_page
{
 public create_page()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //

 }
    public bool writeFile(string ShowArticle, string Showkeywords, string Showdescription,string ShowImgUrl)
    {
        string path = HttpContext.Current.Server.MapPath("news/");
        Encoding code = Encoding.GetEncoding("gb2312");
        // 读取模板文件
        string temp = HttpContext.Current.Server.MapPath("news/1.html");
        StreamReader sr = null;
        StreamWriter sw = null;
        string str = "";
        try
        {
            sr = new StreamReader(temp, code);
            str = sr.ReadToEnd();//读取文件
        }
        catch(Exception ee)
        {
            HttpContext.Current.Response.Write(ee.Message);
            HttpContext.Current.Response.End();
            sr.Close();
        }
        string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
        // 替换内容
        // 这时,模板文件已经读入到名称为str的变量中了
        str = str.Replace("ShowArticle", ShowArticle); //模板页中的ShowArticle
        str = str.Replace("Showkeywords", Showkeywords);
        str = str.Replace("Showdescription", Showdescription);
        str = str.Replace("ShowImgUrl", ShowImgUrl);
        //str = str.Replace("ShowImgUrl", ShowImgUrl);
        //str = str.Replace("ShowImgUrl", ShowImgUrl);
        //str = str.Replace("ShowImgUrl", ShowImgUrl);
        //str = str.Replace("ShowImgUrl", ShowImgUrl);
        // 写文件
        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;
    }
}
 

标签:asp.net生成html静态页  asp.net  生成  html  静态页  生成html静态页  

点击这里获取该日志的TrackBack引用地址

相关文章

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。


图标汇集

最近发表

最新评论及回复

最近留言