Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: MediaTypeFormatterTracer doesn't pass MediaTypeMappings to inner formatter [849]

$
0
0
The particular issue happens when supporting $format to ODataMediaTypeFormatter.

The controller configuration won't work with tracing enabled:

public class ODataFormatQueryAttribute : Attribute, IControllerConfiguration
{
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
{
var formatters = controllerSettings.Formatters.Where(f =>
!f.MediaTypeMappings.OfType<QueryStringMapping>().Any(m => m.QueryStringParameterName == "$format"));

formatters.ToList().ForEach(f =>
{
f.AddQueryStringMapping("$format", "atom", "application/atom+xml");
f.AddQueryStringMapping("$format", "json", "application/json");
f.AddQueryStringMapping("$format", "xml", "application/xml");
});
}
}

The reason is because MediaTypeFormatterTracer doesn't pass MediaTypeMappings to inner formatter. When call GetPerRequestFormatterInstance, it will delegate to inner formatter to create a new one to negotiate. The new one will copy from the inner formatter which doesn't has the mappings.


Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>