说明:我没做过动态转静态,所以不知道什么样的才能转什么不能转。
问题:我们做个一个网站,asp.net开发的,现在要转成时静态的。我知道通过模版可以转成静态的,也实现了。应为这个页面上没有其他的操作按钮什么。只是一个用户浏览的页面,没有用户操作。
我想问的是,如果一个aspx页面,上面有其他操作,比如,有个下载按钮,下载代码是在后台.cs里边写的。还有搜索,代码都是在.cs里边写的。页面还有一些脚本代码。请问这个页面怎么转成时静态的?能不能转。转完还能进行那些操作吗?
我看csdn的就做的很好。不知道是怎么做的!
注:除URL重写(伪静态)外的方法!谢谢。请做过的高手帮忙!高分送上!

解决方案 »

  1.   

    必须重载OnInit和Render实现的静态页面生成 
    但读写个类 
    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; /// <summary> 
    /// change 的摘要说明 
    /// </summary> 
    public class change : System.Web.UI.Page 

        protected string FileName; 
    protected override void OnInit(EventArgs e) 
        { 
            int count = Request.Url.AbsolutePath.Length; 
            FileName = Request.Url.AbsolutePath.Remove(count - 4, 4) + "htm";//把要转换的页面后缀aspx去掉 
            if (File.Exists(Server.MapPath(FileName))) 
            { 
                File.Delete(Server.MapPath(FileName)); 
            } 
        }     protected override void Render(HtmlTextWriter writer) 
        { 
            StringWriter html = new StringWriter(); 
            HtmlTextWriter tw = new HtmlTextWriter(html); 
            base.Render(tw); 
            StreamWriter sw = new StreamWriter(Server.MapPath(this.FileName), false, System.Text.Encoding.UTF8); 
            sw.Write(html.ToString()); 
            sw.Flush(); 
            sw.Close(); 
            tw.Close(); 
            Response.Write(html.ToString()); 
        } 

    要生成静态页的页面只需继承这个类(change)就可以在你的网站路径下面生成了一个静态页面名字和动态页面相同就是是静态页
      

  2.   

    附加内容:
    例如,我要给这个页面做静态,怎么做
    http://60.195.249.197:8088/user/Zsy/Zsy_kejianInfo.aspx?id=599
      

  3.   

    把动态交互的部分全部用AJAX实现!=。=!注意比较馊!ISAPI有没有用?没仔细研究过
      

  4.   

    用伪静态
    或者你把你的asp.net 的页面,点源文件
    复制粘贴,哈哈那就是真真的静态了
      

  5.   


    ASP.NET伪静态 URLwrite
     参考
      

  6.   

    定义静态页模版,根据不同信息替换字符串,生成静态页面
    搜索 下载这样的要求要提交到aspx页处理
      

  7.   

    伪静态,即URLwrite 
    还有一种就是定义好HMTL模板,然后向里面填充、替换数据