Browse Source

Added load timing as a header value

pull/29/head
Teknikode 7 years ago
parent
commit
99dbae3f20
  1. 23
      Teknik/Global.asax.cs
  2. 2
      Teknik/Views/Shared/_Footer.cshtml

23
Teknik/Global.asax.cs

@ -14,6 +14,7 @@ using Teknik.Areas.Profile.Models; @@ -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 @@ -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)

2
Teknik/Views/Shared/_Footer.cshtml

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
string version = fileVersionInfo.ProductVersion;
}
<p class="text-muted">
&copy; Teknik 2013-2015 | <a href="@Url.SubRouteUrl("privacy", "Privacy.Index")">Privacy</a> | <a href="@Url.SubRouteUrl("transparency", "Transparency.Index")">Transparency</a> | <a href="@Url.SubRouteUrl("server", "Server.Index")">Server</a>
&copy; Teknik 2013-2016 | <a href="@Url.SubRouteUrl("privacy", "Privacy.Index")">Privacy</a> | <a href="@Url.SubRouteUrl("transparency", "Transparency.Index")">Transparency</a> | <a href="@Url.SubRouteUrl("server", "Server.Index")">Server</a>
<br />
@string.Format("{0}", version)
</p>

Loading…
Cancel
Save