Question

I have a question, I think it's a little vague but forgive me if it is.

I have custom MediaTypeFormatter that I want to use, but here is the question if I remove all the others formatters would it improve my preformance?

If not I would like to know why also if it is....

Thanks in advance...

Était-ce utile?

La solution

When the HTTP request arrives, WebAPI will look up each formatter's SupportedMediaTypes to get formatter appropriate for the request's Accept-Type. Removing formatters will make look up quicker, but cost of the lookup is very tiny comparing to the serialisation/deserialisation itself and other processes. However, one merit I found out is that by removing all formatters but one we use, we make sure that client will always get our chosen format. By default formatters, clients can choose either Accept: application/json or Accept: text/xml, which might not be something we want e.g. we may not want to support XML at all.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top