Browse Source

Removed unecessary headers.

Added cache headers for favicon and logo
tags/3.0.0
Teknikode 2 years ago
parent
commit
28e6c34748
3 changed files with 19 additions and 7 deletions
  1. 10
    6
      Teknik/Controllers/DefaultController.cs
  2. 8
    0
      Teknik/Global.asax.cs
  3. 1
    1
      Teknik/Web.config

+ 10
- 6
Teknik/Controllers/DefaultController.cs View File

@@ -75,26 +75,30 @@ namespace Teknik.Controllers
// Get the Favicon
[HttpGet]
[AllowAnonymous]
[OutputCache(
Duration = 31536000,
Location = OutputCacheLocation.ServerAndClient)]
public ActionResult Favicon()
{
// Get favicon
string imageFile = Server.MapPath(Constants.FAVICON_PATH);

Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0));
Response.Cache.SetLastModified(System.IO.File.GetLastWriteTime(imageFile));

return File(imageFile, "image/x-icon");
}

// Get the Logo
[HttpGet]
[AllowAnonymous]
[OutputCache(
Duration = 31536000,
Location = OutputCacheLocation.ServerAndClient)]
public ActionResult Logo()
{
// Get favicon
string imageFile = Server.MapPath(Constants.LOGO_PATH);

Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0));
Response.Cache.SetLastModified(System.IO.File.GetLastWriteTime(imageFile));

return File(imageFile, "image/svg+xml");
}


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

@@ -32,6 +32,8 @@ namespace Teknik

AntiForgeryConfig.RequireSsl = true;

MvcHandler.DisableMvcResponseHeader = true;

FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
@@ -45,6 +47,12 @@ namespace Teknik
stopwatch.Start();
}

protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
// Remove stupid headers
HttpContext.Current.Response.Headers.Remove("Server");
}

protected void Application_EndRequest(object sender, EventArgs e)
{
try

+ 1
- 1
Teknik/Web.config View File

@@ -47,7 +47,7 @@
<forms domain=".teknik.io" protection="All" enableCrossAppRedirects="true" name="TeknikAuth" />
</authentication>
<compilation debug="true" targetFramework="4.6.2" />
<httpRuntime targetFramework="4.6.2" maxRequestLength="5242880" executionTimeout="3600" relaxedUrlToFileSystemMapping="true" />
<httpRuntime targetFramework="4.6.2" maxRequestLength="5242880" executionTimeout="3600" relaxedUrlToFileSystemMapping="true" enableVersionHeader="false" />
<pages buffer="true" enableViewState="false" />
</system.web>
<system.webServer>

Loading…
Cancel
Save