This project is read-only.

MediaTypeFormatter and Versioning

Topics: Web Api
Nov 3, 2011 at 1:25 PM


I doesn't seem to be possible to register a mediatypeformatter on a mediatype like this:

application/; version=1.0

What's the recommended way of receiving/returning different versions of an object to/from the same service?




Nov 3, 2011 at 1:57 PM

Just out of curiosity, what do you see as the difference between application/ and application/; version=1.0 ?

Nov 3, 2011 at 2:24 PM

Nothing really.....just thought the correct way of defining a mediatype was by a type and possible a subtype.... so I was just puzzled that when adding a subtype I got an exception....

Could also be something different from version I wanted to specify as subtype....





Nov 3, 2011 at 2:48 PM

In your example, the type is "application", the subtype is "".  The "version" is a parameter of the media type.  To be honest, I have yet to find out what is the real value of using parameters versus just changing the subtype to include the version number, which is why I asked the question.  I do know that conneg considers the parameters when matching content types so it behaves the same way as changing the subtype.

Nov 3, 2011 at 3:06 PM

I don't have much input to this... I'm pretty new to this.... but you're right, it's parameters of the mediatype, so it actually make sense, not to have a different MediaTypeFormatter taking care of the same MediaType but with different parameters...

Guess it's kind of the same as having a method taking an argument or having a different method for each possible outcome of the argument....

   Get(int version)