/// <summary> /// Fills the client response with the contents of the Cache file specified /// </summary> /// <param name="CacheFileName">The name of the cache file</param> public void SendCachedResponse(string CacheFileName) { try { // Make sure we have loaded this file if (CacheFile == null) CacheFile = new FileInfo(Path.Combine(Program.RootPath, "Web", "Bf2Stats", "Cache", CacheFileName + ".html")); // Open the file using (FileStream Stream = CacheFile.Open(FileMode.Open, FileAccess.Read)) using (StreamReader Reader = new StreamReader(Stream)) { // Read our page source string source = Reader.ReadToEnd(); // Replace Http Link Addresses to match the request URL, preventing Localhost links with external requests BF2PageModel Model = new IndexModel(Client); Client.Response.ResponseBody.Append(CorrectUrls(source, Model)); } } catch (Exception e) { Program.ErrorLog.Write("ERROR: [Controller.SendCachedResponse] " + e.Message); Client.Response.ResponseBody.Append("Cache Read Error: " + e.GetType().Name); } // Send Response Client.Response.ContentType = "text/html"; Client.Response.Send(); }
public IndexController(HttpClient Client) : base(Client) { Model = new IndexModel(Client); }