First step: Create a mbpage.html page
Step Two: Background generation
public void ProcessRequest (HttpContext context)
{
Context. Response.ContentType = "Text/plain";
String Mbpath = context. Server.MapPath ("mbpage.html");
Encoding code = encoding.getencoding ("gb2312");
StreamReader sr = null;
StreamWriter SW = null;
string str = NULL;
Read
Try
{
sr = new StreamReader (Mbpath, code);
str = Sr. ReadToEnd ();
}
catch (Exception ex)
{
Throw ex;
}
Finally
{
Sr. Close ();
}
Auto-Rename by time, extension can also be modified by itself
String fileName = DateTime.Now.ToString ("YYYYMMDDHHMMSS") + ". htm";
str = str. Replace ("$title $", "111");//Substitute title
str = str. Replace ("$content $", "2222");//replacement content
Generating static files
Try
{
SW = new StreamWriter (context. Server.MapPath ("htm/") + FileName, false, code);
Sw. Write (str);
Sw. Flush ();
}
catch (Exception ex)
{
Throw ex;
}
Finally
{
Sw. Close ();
Context. Response.Write ("Congratulations <a href=htm/" + filename + "target=_blank>" + filename + "</a> has been generated, saved in the HTM folder! ");
}
Context. Response.End ();
}
Generating HTML files