ASP.NET中怎么实现页面静态化

ASP.NET中怎么实现页面静态化,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

ASP.NET页面静态化***步:首页选择HTML原型网页

然后再该HTML网页添加一些自认为特别的标记,已便到时候静态化的时候系统能更精确的进行操作!

ASP.NET页面静态化第二步:获取HTML网页代码

我选择的是通过FileUpload控件进行获取静态度页面模型,进行保存!

if (FileUpload1.PostedFile.FileName == "")   {   Response.Write("");   return;   }   if ((FileUpload1.FileName.LastIndexOf(".") != "htm") ||   (FileUpload1.FileName.LastIndexOf(".") != "html"))   {   Response.Write("");   return;   }   System.Text.Encoding ec = System.Text.Encoding.  GetEncoding("gb2312");//指定编码格式   System.IO.StreamReader sr = new System.IO.StreamReader  (FileUpload1.PostedFile.FileName, ec);   string strHTML =Convert.ToString(sr.ReadToEnd());   strHTML=FormatStr(strHTML); //格式化HTML代码后,  将此strHTML插入数据库 已便使用时候提取!   sr.Close();   //贴上格式化HTML方法代码   ///    /// 格式 化 HTML   ///    ///    ///    private string FormatStr(string str)   {   string strContent = str.Replace("<", "<");   strContent = strContent.Replace(">", ">");   //strContent = strContent.Replace(chr(13),"   ");   strContent = strContent.Replace(" ", "   ");   strContent = strContent.Replace(" ", " ");   strContent = strContent.Replace("[isOK]", "    strContent = strContent.Replace("[red]", "");   strContent = strContent.Replace("[big]", "");   strContent = strContent.Replace("[/isOK]", ">");   strContent = strContent.Replace("[/b]", "");   strContent = strContent.Replace("[/red]", "");   strContent = strContent.Replace("[/big]", "");   return strContent;   }

ASP.NET页面静态化第三步:提取先前保存过的HTML页面模型

然后通过 string.Replace(char oldstring,char newstring );

对模型页面中预先 设置好的特别标记进行替换成我们需要动态更改的!

ASP.NET页面静态化第四步:对动态更新后的HTML代码进行文件进行保存 平把路径存如数据库方便调用!

    关于ASP.NET中怎么实现页面静态化问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。