BF2Statistics.Web.Bf2Stats.Controller.SendCachedResponse C# (CSharp) Method

SendCachedResponse() public method

Fills the client response with the contents of the Cache file specified
public SendCachedResponse ( string CacheFileName ) : void
CacheFileName string The name of the cache file
return void
        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();
        }