A while ago, a buddy asked me how to generate HTML static pages from a template?
First, generate HTML benefits
HTML is static, needless to say, the speed is certainly faster (without reading the database can not be unpleasant?)
More secure, out of the database, preventing SQL injection, and so on.
More conducive to the seo,html page is more easily included, this to webmaster friends, may be more concerned about.
Two, ASP. HTML Implementation method
Dry goods directly on the code:
Public static bool writefile (String strtext,string strcontent,string strauthor) { string path = HttpContext.Current.Server.MapPath ("/news/"); encoding code = Encoding.GetEncoding ("gb2312"); // read template file 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 (); // Read file } catch (exception exp) { httpcontext.current.response.write (exp. Message); &nBsp; httpcontext.current.response.end (); sr. Close (); } string htmlfilename=datetime.now.tostring ("YYYYMMDDHHMMSS") + ". html"; // replace content // at this point, the template file has been read into the variable named str str =str. Replace ("Showarticle", StrText), //showarticle str = str in the template page. Replace ("Biaoti", StrText); str = str. Replace ("Content", strcontent); str = str. Replace ("Author", Strauthor); // write file 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;}
Source: http://www.csaspx.com/articlelist-6566.html
ASP. NET templates generate HTML pages