-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileStreamCacheResult.cs
38 lines (35 loc) · 1.27 KB
/
FileStreamCacheResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
namespace AzureArtifactsPublicNuGetFeedBadge
{
public class FileStreamCacheResult : FileStreamResult
{
public FileStreamCacheResult(Stream fileStream, string contentType)
: base(fileStream, contentType)
{
}
/// <summary>
/// Creates a new <see cref="FileStreamResult"/> instance with
/// the provided <paramref name="fileStream"/> and the
/// provided <paramref name="contentType"/>.
/// </summary>
/// <param name="fileStream">The stream with the file.</param>
/// <param name="contentType">The Content-Type header of the response.</param>
public FileStreamCacheResult(Stream fileStream, MediaTypeHeaderValue contentType)
: base(fileStream, contentType)
{
}
public override Task ExecuteResultAsync(ActionContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
context.HttpContext.Response.Headers.Add("Cache-Control", "public, max-age=600");
return base.ExecuteResultAsync(context);
}
}
}