diff --git a/Build.bat b/Build.bat index 6adb3aa..7e5aeb3 100644 --- a/Build.bat +++ b/Build.bat @@ -1 +1 @@ -%systemroot%\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe /m build.proj /t:%* +"c:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/msbuild.exe" /m build.proj /t:%* \ No newline at end of file diff --git a/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs b/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs index 317a0bc..bbcbf2d 100644 --- a/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs +++ b/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs @@ -205,7 +205,16 @@ public override void OnActionExecuting(HttpActionContext actionContext) if (val == null) return; var contenttype = _webApiCache.Get(cachekey + Constants.ContentTypeKey) ?? responseMediaType; - var contentGenerationTimestamp = DateTimeOffset.Parse(_webApiCache.Get(cachekey + Constants.GenerationTimestampKey)); + var contentGeneration = _webApiCache.Get(cachekey + Constants.GenerationTimestampKey); + + DateTimeOffset? contentGenerationTimestamp = null; + if (contentGeneration != null) + { + if (DateTimeOffset.TryParse(contentGeneration, out DateTimeOffset parsedContentGenerationTimestamp)) + { + contentGenerationTimestamp = parsedContentGenerationTimestamp; + } + }; actionContext.Response = actionContext.Request.CreateResponse(); actionContext.Response.Content = new ByteArrayContent(val); diff --git a/test/WebApi.OutputCache.V2.Tests/ClientSideTests.cs b/test/WebApi.OutputCache.V2.Tests/ClientSideTests.cs index e4b8cc0..132fa5f 100644 --- a/test/WebApi.OutputCache.V2.Tests/ClientSideTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/ClientSideTests.cs @@ -123,7 +123,7 @@ public void maxage_mustrevalidate_headers_correct_with_cacheuntil() { var client = new HttpClient(_server); var result = client.GetAsync(_url + "Get_until25012015_1700").Result; - var clientTimeSpanSeconds = new SpecificTime(2017, 01, 25, 17, 0, 0).Execute(DateTime.Now).ClientTimeSpan.TotalSeconds; + var clientTimeSpanSeconds = new SpecificTime(2019, 01, 25, 17, 0, 0).Execute(DateTime.Now).ClientTimeSpan.TotalSeconds; var resultCacheControlSeconds = ((TimeSpan) result.Headers.CacheControl.MaxAge).TotalSeconds; Assert.IsTrue(Math.Round(clientTimeSpanSeconds - resultCacheControlSeconds) == 0); Assert.IsFalse(result.Headers.CacheControl.MustRevalidate); diff --git a/test/WebApi.OutputCache.V2.Tests/TestControllers/SampleController.cs b/test/WebApi.OutputCache.V2.Tests/TestControllers/SampleController.cs index d3b2b11..69c1f20 100644 --- a/test/WebApi.OutputCache.V2.Tests/TestControllers/SampleController.cs +++ b/test/WebApi.OutputCache.V2.Tests/TestControllers/SampleController.cs @@ -74,7 +74,7 @@ public string Get_s50_exclude_true(int id) return "test" + id; } - [CacheOutputUntil(2017,01,25,17,00)] + [CacheOutputUntil(2019,01,25,17,00)] public string Get_until25012015_1700() { return "test";