Global.asax içindeki Application_Start metodunun içine XML Format ile ilgili herhangi bir kod eklemeden aşağıdaki kodu ekleyelim.

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

Yukarıdaki kodu ekleyip çalıştırdıktan sonra

http://localhost:6624/api/values/getvalues/6

yazıp browserdan request yaptığımızda

This XML file does not appear to have any style information associated with it. The document tree is shown below.

value1
value2

şeklinde bir ekran çıktısı verecektir.

http://localhost:6624/api/values/getvalues/6?json=true

yazıp browserdan request yaptığımızda ise result json olarak aşağıdaki gibi döndürülecektir.

[“value1″,”value2”]