C # method for generating static pages: C # method for generating static pages private bool CreateHl (string strtext, string strcontent, string author) {string yearstring = DateTime. now. year. toString (); string monthstring = DateTime. now. month. toString (); string daystring = DateTime. now. day. toString (); string filename = yearstring + monthstring + daystring + DateTime. now. millisecond. toString () + ". html "; Directory. createDirectory (Server. mapPath ("" + years Tring + "//" + monthstring + "//" + daystring + ""); Encoding code = Encoding. getEncoding ("gb2312"); string temp = Server. mapPath ("test.htm"); Response. write (temp); // Response. end (); StreamReader sr = null; StreamWriter sw = null; string str = ""; try {sr = new StreamReader (temp, code); str = sr. readToEnd ();} catch (Exception exp) {Response. write (exp. message); Response. end (); sr. close ();} strcontent + = strconte Nt. replace ("\ n", "<br>"); strcontent + = strcontent. replace ("\ r", "<br>"); str = str. replace ("{pagetitle}", strtext); str = str. replace ("{title}", strtext); str = str. replace ("{content}", strcontent); str = str. replace ("{author}", author); try {// sw = new StreamWriter (str, code); // sw. writeLinesw = new StreamWriter (Server. mapPath ("" + yearstring + "//" + monthstring + "//" + daystring + "//" + filename + ""), False, code); // sw. write; sw. write (str); sw. flush ();} catch (Exception exp) {HttpContext. current. response. write (exp); HttpContext. current. response. end ();} finally {sw. close ();} msg. text = filename; return true;} use protected void Button2_Click (object sender, EventArgs e) {string title = txttitle. text; string content = txtcontent. text; string zuozhe = txtzuzhe. text; bool SC; SC = CreateHl (title, content, zuo Zhe); if (SC) {Response. Write ("HTML generated successfully! ");} Else {Response. Write (" HTML generation failed! ");}}