ASP Net Web Api : define data format in url

Content negotiation is one of the strong pointy in web api and thats pretty cool. 

Now i can just change the type of response via url only. 

To achieve this just add the following  one line of code 

GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping(“format”, “json”, “application/json”));

 

Now i can get json via url : 

http://localhost:18308/api/values?format=json

for xml 

http://localhost:18308/api/values

OR 

http://localhost:18308/api/values?format=xml

 

 

 

 

Advertisements

VS2010 causes blue screen error on windows

VS 2010 uses the WPF hardware acceleration . This causes   famous blue scree error (depends  on hardware ).

Below is a fix which worked for me :

 

1. Go to VS 2010 Tools->Options

image

2.  Go to Environment –>  General

  Disable Visual experience check box.

 

image