Browse Source

Added load timing as a header value

tags/2.0.3
Teknikode 4 years ago
parent
commit
99dbae3f20
2 changed files with 24 additions and 1 deletions
  1. 23
    0
      Teknik/Global.asax.cs
  2. 1
    1
      Teknik/Views/Shared/_Footer.cshtml

+ 23
- 0
Teknik/Global.asax.cs View File

@@ -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)

+ 1
- 1
Teknik/Views/Shared/_Footer.cshtml View File

@@ -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