Skip to content

Commit 0b5f8c3

Browse files
Yue ShiYue Shi
authored andcommitted
Use request MediaType if ContentType cache returns null
1 parent 1129abc commit 0b5f8c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/WebApi.OutputCache.V2/CacheOutputAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public override void OnActionExecuting(HttpActionContext actionContext)
176176
var val = _webApiCache.Get<byte[]>(cachekey);
177177
if (val == null) return;
178178

179-
var contenttype = _webApiCache.Get<MediaTypeHeaderValue>(cachekey + Constants.ContentTypeKey) ?? new MediaTypeHeaderValue(cachekey.Split(new[] { ':' }, 2)[1].Split(';')[0]);
179+
var contenttype = _webApiCache.Get<MediaTypeHeaderValue>(cachekey + Constants.ContentTypeKey) ?? responseMediaType;
180180

181181
actionContext.Response = actionContext.Request.CreateResponse();
182182
actionContext.Response.Content = new ByteArrayContent(val);

0 commit comments

Comments
 (0)