cs文件:
using System.IO;
string context = "";
string path = HttpContext.Current.Server.MapPath("") + "//test//test.html";
System.Text.Encoding code = System.Text.Encoding.GetEncoding("utf-8");
StreamReader sr = null;
try
{
sr = new StreamReader(path, code);
context = sr.ReadToEnd();
context = context.Replace("<firstname>", "小虫");
context = context.Replace("<lastname>", "爬爬");
Response.Write(context);
sr.Close();
}
catch (Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}