From 99dbae3f20ef1c7b30d1296af43c74eb8c1a7915 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Tue, 5 Jan 2016 12:06:57 -0800 Subject: [PATCH] Added load timing as a header value --- Teknik/Global.asax.cs | 23 +++++++++++++++++++++++ Teknik/Views/Shared/_Footer.cshtml | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Teknik/Global.asax.cs b/Teknik/Global.asax.cs index 9dbb47b..e00f0d4 100644 --- a/Teknik/Global.asax.cs +++ b/Teknik/Global.asax.cs @@ -14,6 +14,7 @@ using Teknik.Areas.Profile.Models; using System.ComponentModel; using Teknik.Areas.Error.Controllers; using System.Web.Helpers; +using System.Diagnostics; namespace Teknik { @@ -33,6 +34,28 @@ namespace Teknik BundleConfig.RegisterBundles(BundleTable.Bundles); } + protected void Application_BeginRequest(object sender, EventArgs e) + { + HttpContext context = HttpContext.Current; + + var stopwatch = new Stopwatch(); + HttpContext.Current.Items["Stopwatch"] = stopwatch; + stopwatch.Start(); + } + + protected void Application_EndRequest(object sender, EventArgs e) + { + HttpContext context = HttpContext.Current; + + Stopwatch stopwatch = (Stopwatch)context.Items["Stopwatch"]; + stopwatch.Stop(); + + TimeSpan ts = stopwatch.Elapsed; + string elapsedTime = String.Format("{0} seconds", ts.TotalSeconds); + + context.Response.AddHeader("LoadTime", elapsedTime); + } + protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) { if (FormsAuthentication.CookiesSupported == true) diff --git a/Teknik/Views/Shared/_Footer.cshtml b/Teknik/Views/Shared/_Footer.cshtml index f1909cb..6b61cbd 100644 --- a/Teknik/Views/Shared/_Footer.cshtml +++ b/Teknik/Views/Shared/_Footer.cshtml @@ -9,7 +9,7 @@ string version = fileVersionInfo.ProductVersion; }

- © Teknik 2013-2015 | Privacy | Transparency | Server + © Teknik 2013-2016 | Privacy | Transparency | Server
@string.Format("{0}", version)