asp.net-web-api


How do I set or remove the Default Response Content Type Using SwashBuckle


The default response content type when using SwashBuckle is text/plain. How can I change the default to be application/json or even remove text/plain?
The response content of an end point is not determined by Swashbuckle but by the formatters set in the configuration of your ASP.NET Web API project.
To remove the text/plain content type and only support application\json you could add this to the Register method of your WebApiConfig:
GlobalConfiguration.Configuration.Formatters.Clear();
var jsonFormatter = new JsonMediaTypeFormatter();
jsonFormatter.SupportedMediaTypes.Clear();
jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue('application\json'));
GlobalConfiguration.Configuration.Formatters.Add(jsonFormatter);

Related Links

SignalR Authorize attribute not called
Elmah.axd on WebAPI 2.2 - No HTTP Resource was found
OData attribute routing for deleting relationship between m:m entities
Sitecore GetChildren empty just after child item created
JsonFormatter in WebApi is ignored
Partial Authentication after expired token
Web api routing use only RoutePrefix
Differentiate between MVC and WebAPI in ASP.NET 5 / MVC 6
How to authenticate ionic app with Asp.net WebApi
Web Api and where should I contorol Request Header data
Authorize roles specific to category-branch
Cannot read property 'client' of undefined using SignalR
Odata endpoint returning 404 bad request when the “$” in filter is encoded
Odata web api 404 error
Webapi Controller - Routing not working
AutoFac does not register api controller

Categories

HOME
phantom-dsl
adal
pascal
fftw
obfuscation
mstest
sitecore
solver
grafana
replace
tivoli
vxml
nested-if
maxscript
zip
iis-6
openstreetmap
minecraft-forge
endeca
onedrive-api
nodemcu
breadth-first-search
articulate-storyline
guzzle
ksh
href
exploit
xunit
asymptotic-complexity
sinch
bringtofront
paperjs
volatile
utorrent
catch-unit-test
activexobject
nested-lists
indy10
filesystemwatcher
opensmpp
trigonometry
laravel-elixir
branching-and-merging
movilizer
smoothstate.js
clang++
jquery-ui-draggable
fclose
reindex
video-conferencing
java-6
filehandle
cup
quicktime
meteor-packages
centrifuge
dotnetnuke-7
simevents
mediametadataretriever
dbamp
atan2
directdraw
grgit
vigenere
finalbuilder
git-ftp
uvc
fits
dot.js
at-job
primitive-types
sql-scripts
jjaql
radiant
synapse
qscrollarea
sphinxql
kogrid
observium
asdf
time.h
cascadingdropdown
usertype
jsr286
cgimage
relative
rmdir
umra
cloudfiles
commerceserver2007
cruisecontrol.rb
maven-1
jqueryform
aspmenu
interop-domino
xpsdocument
todos
flvplayback
business-model
dsoframer
xslcompiledtransform

Resources

Encrypt Message