想搞个静态列表 分页,想了N久,终于把静态文件都生成,以为结束了,突然发现一个大问题。
生成的counthmtl_2.html的文件,下一页,上一页还是保持动态连接?兄弟们接力~~~~还是说我这种方式是不可行的? int count = SqlHelper.ExecuteCountSql(SqlHelper.LocalSqlServer, "select count(*) from tb_news");
int page = 2;
int StrCount; if (count % page == 0)
{
StrCount = count / page;
}
else
{
StrCount = count / page + 1;
}
if (StrCount > 1)
{
for (int i = 0; i < StrCount; i++)
{
int dd = 2 + i;
string filename = "counthtml.aspx?page=" + dd;
string serverport = Request.ServerVariables["SERVER_PORT"].ToString();
string PageUrl = "";
if (serverport == "80")
{
PageUrl = "http://" + Request.Url.Host + "/" + filename;
}
else
{
PageUrl = "http://" + Request.Url.Host + ":" + Request.ServerVariables["SERVER_PORT"] + "/" + filename;
}
WebRequest request = WebRequest.Create(PageUrl);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.GetEncoding("utf-8"));
string InfoHtml = sr.ReadToEnd();
resStream.Close();
sr.Close();
string fileName = "counthmtl_" + dd + ".html";
StreamWriter sw = new StreamWriter(Server.MapPath("/") + fileName, false, System.Text.Encoding.GetEncoding("utf-8"));
sw.Write(InfoHtml);
sw.Flush();
sw.Close();
}
}
生成的counthmtl_2.html的文件,下一页,上一页还是保持动态连接?兄弟们接力~~~~还是说我这种方式是不可行的? int count = SqlHelper.ExecuteCountSql(SqlHelper.LocalSqlServer, "select count(*) from tb_news");
int page = 2;
int StrCount; if (count % page == 0)
{
StrCount = count / page;
}
else
{
StrCount = count / page + 1;
}
if (StrCount > 1)
{
for (int i = 0; i < StrCount; i++)
{
int dd = 2 + i;
string filename = "counthtml.aspx?page=" + dd;
string serverport = Request.ServerVariables["SERVER_PORT"].ToString();
string PageUrl = "";
if (serverport == "80")
{
PageUrl = "http://" + Request.Url.Host + "/" + filename;
}
else
{
PageUrl = "http://" + Request.Url.Host + ":" + Request.ServerVariables["SERVER_PORT"] + "/" + filename;
}
WebRequest request = WebRequest.Create(PageUrl);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.GetEncoding("utf-8"));
string InfoHtml = sr.ReadToEnd();
resStream.Close();
sr.Close();
string fileName = "counthmtl_" + dd + ".html";
StreamWriter sw = new StreamWriter(Server.MapPath("/") + fileName, false, System.Text.Encoding.GetEncoding("utf-8"));
sw.Write(InfoHtml);
sw.Flush();
sw.Close();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货