先生成html到服务器硬盘上,然后根据WebClient这个类去download那个html文件,下面那个Replace不是替换成html,这边是设置后缀,不是很了解的可以参照微软的msdn看一下webclient类。
这是真正的静态页
原理很简单
这是真正的静态页
原理很简单
1 public class SetRemoteURL
2 {
3 static string str2HTML = string.Empty;
4 public SetRemoteURL() { }
5 /// <summary>
6 /// to THML
7 /// </summary>
8 /// <param name="strWebFromName">要转换的aspx文件,带后缀</param>
9 public static void Convert(string strWebFormName)
10 {
11 str2HTML = str2HTML.ToLower();
12 str2HTML = strWebFormName.Replace(".aspx", ".html");
13
14 string strURL = "http://" + HttpContext.Current.Request.Url.Authority + "/" + strWebFormName;
15 new System.Net.WebClient().DownloadFile(strURL, System.Web.HttpContext.Current.Server.MapPath("~/" + str2HTML));
16 HttpContext.Current.Response.Redirect(str2HTML);
17 }
18 }
2 {
3 static string str2HTML = string.Empty;
4 public SetRemoteURL() { }
5 /// <summary>
6 /// to THML
7 /// </summary>
8 /// <param name="strWebFromName">要转换的aspx文件,带后缀</param>
9 public static void Convert(string strWebFormName)
10 {
11 str2HTML = str2HTML.ToLower();
12 str2HTML = strWebFormName.Replace(".aspx", ".html");
13
14 string strURL = "http://" + HttpContext.Current.Request.Url.Authority + "/" + strWebFormName;
15 new System.Net.WebClient().DownloadFile(strURL, System.Web.HttpContext.Current.Server.MapPath("~/" + str2HTML));
16 HttpContext.Current.Response.Redirect(str2HTML);
17 }
18 }