You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
When a client sends in multiple values in Accept header doing a check on that header fails the Contains method.
Looking at the Accept header it is a StringValues type which implements the many ICollection,IList,IEnumerable etc interfaces and the value of the Accept header is 1 entry with a string separated by comma. Therefore a IList.Contains will fail because there isn't an entry that matches application/json when the entry is application/json, text/plain, */*
I would have expected 3 entries in the result of calling context.Request.Headers["Accept"] which would have made the check pass. For now I will have to use context.Request.Headers["Accept"].Any(h => h.Contains("application/json")) or context.Request.Headers["Accept"].ToString().Contains("application/json"))
Attached is a screenshot of my debug window which shows what I saw.
When a client sends in multiple values in
Acceptheader doing a check on that header fails theContainsmethod.Looking at the
Acceptheader it is aStringValuestype which implements the manyICollection,IList,IEnumerableetc interfaces and the value of theAcceptheader is 1 entry with a string separated by comma. Therefore aIList.Containswill fail because there isn't an entry that matchesapplication/jsonwhen the entry isapplication/json, text/plain, */*I would have expected 3 entries in the result of calling
context.Request.Headers["Accept"]which would have made the check pass. For now I will have to usecontext.Request.Headers["Accept"].Any(h => h.Contains("application/json"))orcontext.Request.Headers["Accept"].ToString().Contains("application/json"))Attached is a screenshot of my debug window which shows what I saw.