下面黄色部份有问题,在生成静态html页成的时候内容不能循环替换。可我在调试的时候是能读取绿部分已经分组的内容的。不知道什么原因
string filename = "/infoSkin.aspx?NewsID=" + Util.Encode(strNewsID.ToString());
string serverport = Request.ServerVariables["SERVER_PORT"].ToString();
string PageUrl = "";
string ipath = Server.MapPath("/Html/" + mnews.Addtime.ToString("yyMMdd") + "/");
if (Directory.Exists(ipath) == false)
{
Directory.CreateDirectory(ipath);
}
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();
InfoHtml = InfoHtml.Replace("$title$", mnews.Title);
resStream.Close();
sr.Close();
string[] strPage = mnews.Content.Split('|');
string fileName = "";
StreamWriter sw = null;
StringBuilder sb = new StringBuilder("");
for (int i = 0; i < strPage.Length; i++)
{
string aa = strPage[i];
string dd = aa; InfoHtml = InfoHtml.Replace("$content$",strPage[i]);
sb.Append(i.ToString());
// InfoHtml = InfoHtml.Replace("$page$", sb.ToString());
fileName = mnews.Addtime.ToString("yyyyMMddhhmmss_" + i) + ".html";
sw = new StreamWriter(ipath + fileName, false, System.Text.Encoding.GetEncoding("gb2312"));
sw.Write(InfoHtml);
}
sw.Flush();
sw.Close();
string filename = "/infoSkin.aspx?NewsID=" + Util.Encode(strNewsID.ToString());
string serverport = Request.ServerVariables["SERVER_PORT"].ToString();
string PageUrl = "";
string ipath = Server.MapPath("/Html/" + mnews.Addtime.ToString("yyMMdd") + "/");
if (Directory.Exists(ipath) == false)
{
Directory.CreateDirectory(ipath);
}
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();
InfoHtml = InfoHtml.Replace("$title$", mnews.Title);
resStream.Close();
sr.Close();
string[] strPage = mnews.Content.Split('|');
string fileName = "";
StreamWriter sw = null;
StringBuilder sb = new StringBuilder("");
for (int i = 0; i < strPage.Length; i++)
{
string aa = strPage[i];
string dd = aa; InfoHtml = InfoHtml.Replace("$content$",strPage[i]);
sb.Append(i.ToString());
// InfoHtml = InfoHtml.Replace("$page$", sb.ToString());
fileName = mnews.Addtime.ToString("yyyyMMddhhmmss_" + i) + ".html";
sw = new StreamWriter(ipath + fileName, false, System.Text.Encoding.GetEncoding("gb2312"));
sw.Write(InfoHtml);
}
sw.Flush();
sw.Close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货