asp里面可以把.asp文件转换成htm文件
.net里面怎么把.aspx文件转换成htm文件
高手指导~~
100分承上~~~~~~;]

解决方案 »

  1.   

    何利用ASP.NET技术动态生成HTML页面http://tech.sina.com.cn/c/2004-09-09/1034421727.shtml
      

  2.   

    换成html的?但是aspx的有服务器端控件啊?我不确定能不能换~但是我感觉应该是不行
      

  3.   

    /*
     * 环境:Microsoft .NET Framework SDK v1.1 
    OS:Windows Server 2003 中文版
    ASP.Net生成静态HTML页
    在Asp中实现的生成静态页用到的FileSystemObject对象!
    在.Net中涉及此类操作的是System.IO 
    以下是程序代码 注:此代码非原创!参考别人代码
    */
    //生成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;
    //此函数放在Conn.CS基类中了
    //在添加新闻的代码中引用 注:工程名为Hover 
    if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString)))
    {
    Response.Write("添加成功");
    }
    else
    {
    Response.Write("生成HTML出错!");
    }
    /* -------------------------------------------------------------------------
    模板页Text.html代码
    -------------------------------------------------------------------------
    */
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>ShowArticle</title>
      
    <body>biaoti
    <br>
    content<br>
    author
    </body>
    </HTML>  /*------------------------------------------------------------------------
    提示添加成功后会出以当前时间为文件名的html文件!上面只是把传递过来的几个参数直接写入了HTML文件中,在实际应用中需要先添加数据库,然后再写入HTML文件
    而且需要把生成的文件名等写入数库以便以后调用等,此实例只是实现了根据提交过来参数替换模板中的相应的字段! 需要完善的地方很多!哪位有高见,欢迎赐教!
    posted on 2004-03-23 15:39 观自在书院 阅读(220) 评论(3)  编辑 收藏 
    评论
    # re: ASP.Net生成静态HTML页! 2004-05-17 09:37 Kriss 
    用HTML作为模板,替换其中变量只能实现一些简单页面 
    有没有办法把我的ASPX文件的运行结果产生HTML呢? 
    譬如我的首页,内容很复杂,用ASPX写的 
    但由于用户很多,为了提高速度,我每次更新数据后,重新产生首页的HTML,但模板是ASPX文件  # re: ASP.Net生成静态HTML页! 2004-05-18 18:03 槛上人 
    这个效果用缓存可以实现的,比如你将页面整体缓存3分种,和静态页面差不多了  # re: ASP.Net生成静态HTML页! 2004-06-01 13:36 Kriss 
    我找到我想用的方法了:*/ using System.Web.Hosting; WebHost host = (WebHost)ApplicationHost.CreateApplicationHost( 
    typeof(WebHost), name, path); public void DoRequest(string page, string query, TextWriter writer) 

    HttpRuntime.ProcessRequest(new SimpleWorkerRequest(page, query, writer)); 
    } //这样我就可以直接把一个ASPX文件产生HTML文件了 FileStream fs = File.Open("Default.htm"); 
    host.DoRequest("Default.aspx",string.Empty,fs);//下面的为实现的过程
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Text;
    namespace news
    {
    /// <summary>
    /// _111 的摘要说明。
    /// </summary>
    public class _111 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox title;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    }
    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.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.Replace("ShowArticle",strText); //t模板页中的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;
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    string strtext=title.Text;
    string strcontent="11111";
    string strauthor="sssssaaaa"; bool a=WriteFile(strtext,strcontent,strauthor);
    if (a==true)
    {
    Page.Visible=false;
    Response.Write("操作成功");
    } }
    }
    }
      

  4.   

    其实是取aspx文件生成的html标志另存为页面啦
      

  5.   

    用HTML作为模板,替换其中变量只能实现一些简单页面 
    有没有办法把我的ASPX文件的运行结果产生HTML呢? 
    譬如我的首页,内容很复杂,用ASPX写的 
    但由于用户很多,为了提高速度,我每次更新数据后,重新产生首页的HTML,但模板是ASPX文件 
    wanjun830说的正是我的问题 简单的htm模版不是我想要的 
    找了N久没得到解决,高手指点指点小第吧~~~~~~~~ ;]
      

  6.   

    如果是使用ASP,要把asp文件转为html的话,我会考虑用xmlhttp组件,获取一个asp执行过后的内容,存成相应的html就是了.C#中应该也有相应的方法的吧,无外呼就是把浏览器看到html代码存一下咯 .
      

  7.   

    友情帖 :
    http://community.csdn.net/Expert/topic/4036/4036507.xml?temp=.9180872帮忙看看 ,谢谢 ~~~~~~~
      

  8.   

    System.Text.Stringbuilder str= new System.Text.Stringbuilder ();
    str.Append(@"<html></html>");
    Page.Respose.write(str.ToString());
      

  9.   

    lwn19820725(叶男)  能具体一点吗?