VAR.WebFormsCore: Migrate PrepareCacheableResponse and PrepareUncacheableResponse to net5 api

This commit is contained in:
2021-06-26 05:54:14 +02:00
parent 251cacdb00
commit d0f30af288

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http; using System;
using Microsoft.AspNetCore.Http;
using VAR.Json; using VAR.Json;
namespace VAR.WebFormsCore.Code namespace VAR.WebFormsCore.Code
@@ -38,21 +39,17 @@ namespace VAR.WebFormsCore.Code
public static void PrepareCacheableResponse(this HttpResponse response) public static void PrepareCacheableResponse(this HttpResponse response)
{ {
// TODO: Implement on asp.net core const int secondsInDay = 86400;
//const int secondsInDay = 86400; response.Headers.Add("Cache-Control", string.Format("public, max-age={0}", secondsInDay));
//response.ExpiresAbsolute = DateTime.Now.AddSeconds(secondsInDay); string ExpireDate = DateTime.UtcNow.AddSeconds(secondsInDay).ToString("ddd, dd MMM yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
//response.Expires = secondsInDay; response.Headers.Add("Expires", ExpireDate + " GMT");
//response.Cache.SetCacheability(HttpCacheability.Public);
//response.Cache.SetMaxAge(new TimeSpan(0, 0, secondsInDay));
} }
public static void PrepareUncacheableResponse(this HttpResponse response) public static void PrepareUncacheableResponse(this HttpResponse response)
{ {
// TODO: Implement on asp.net core response.Headers.Add("Cache-Control", "max-age=0, no-cache, no-store");
//response.ExpiresAbsolute = DateTime.Now.AddDays(-2d); string ExpireDate = DateTime.UtcNow.AddSeconds(-1500).ToString("ddd, dd MMM yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
//response.Expires = -1500; response.Headers.Add("Expires", ExpireDate + " GMT");
//response.Headers.Add("Cache-Control", "max-age=0, no-cache, no-store");
//response.BufferOutput = true;
} }
#endregion HttpContext #endregion HttpContext