protected void Page_Load(object sender, EventArgs e) { if (QliliHelper.Books.Count == 0) { if (Request.Url.ToString().EndsWith(".aspx")) { if (System.IO.File.Exists(Server.MapPath("./books.xml"))) { // var d=System.IO.File.ReadAllBytes(); System.IO.StringReader sw = new System.IO.StringReader(System.IO.File.ReadAllText(Server.MapPath("./books.xml"))); var seral = new System.Xml.Serialization.XmlSerializer(Skybot.Cache.QliliHelper.Books.GetType()); var sd = seral.Deserialize(sw); Skybot.Cache.QliliHelper.Books = (List <TygModel.书名表>)sd; Skybot.Cache.QliliHelper.Books = Skybot.Cache.QliliHelper.Books.Where(p => System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + p.GetHTMLFilePath())).ToList(); } Response.Write("<!-- count 0 -->"); string url = Request.Url.LocalPath.Replace(".aspx", ".html"); if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + url)) { Server.Transfer(url); return; } //使用url string result = QliliHelper.BookList(); if (!string.IsNullOrEmpty(result)) { Response.Write(result); QliliHelper.WirteFile(url, result); Response.End(); return; } } } else { Response.Write("<!-- count " + Skybot.Cache.QliliHelper.Books.Count + " -->"); } if (!string.IsNullOrEmpty(Request.QueryString["html"])) { bool.TryParse(Request.QueryString["html"], out IsCresteHTMLPage); } ShowNews.EnableViewState = false; TypeName = "玄幻,修真,都市,穿越,网游,科幻"; if (!IsPostBack) { if (string.IsNullOrEmpty(Request["keyword"])) { BindData(); } else { BindData(Request["keyword"]); } } }