Tuesday 15 February 2011

c# - Content-Type - WebAPI - Request Header -



c# - Content-Type - WebAPI - Request Header -

is possible webapi controller homecoming json, if header "content-type" not present?

in default setup, when header not present, exception "no mediatypeformatter available read object of type ..." raising.

add webapiconfig.cs

config.formatters.jsonformatter.supportedmediatypes.add(new mediatypeheadervalue("text/html") );

now json result unless when send text/xml "content-type"

c# asp.net .net json asp.net-web-api

No comments:

Post a Comment