Using the newer ASP.NET Web API, in Chrome I am seeing XML - how can I change it to request JSON so I can view it in the browser? I do believe it is just part of the request headers, am I correct in that?
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Easiest way to get json and parse it using JQuery
- Newtonsoft DeserializeXNode expands internal array
相关文章
- json_encode 没有把数组转为json
- Livy Server: return a dataframe as JSON?
- Unexpected end of JSON input from an ajax call
- How do I do a nested list (array) of schema refere
- iconv() Vs. utf8_encode()
- Convert C# Object to Json Object
- LINQ .Include() properties from sub-types in TPH i
- How to make a custom list deserializer in Gson?
WebApiConfig is the place where you can configure whether you want to output in json or xml. by default it is xml. in the register function we can use HttpConfiguration Formatters to format the output . System.Net.Http.Headers => MediaTypeHeaderValue("text/html") is require to get the output in the json format.
MVC4 Quick Tip #3–Removing the XML Formatter from ASP.Net Web API
In
Global.asax
add the line:like so:
In the WebApiConfig.cs, add to the end of the Register function:
Source.
as per latest version of ASP.net WebApi 2,
under
WebApiConfig.cs
, this will workIn the Global.asax I am using the code below. My URI to get JSON is
http://www.digantakumar.com/api/values?json=true