Skip to content

Instantly share code, notes, and snippets.

Forked from darrelmiller/gist:1989131
Created March 7, 2012 15:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Conneg with quality
public void ConnegTest()
var selector = new FormatterSelector();
var response = new HttpResponseMessage();
response.RequestMessage = new HttpRequestMessage();
var headers = response.RequestMessage.Headers;
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json",0.8));
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
var context = new FormatterContext(response, false);
var mediaType = new MediaTypeHeaderValue("text/plain");
selector.SelectWriteFormatter(typeof (String), context,new MediaTypeFormatterCollection(),out mediaType);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment