Last post Jul 30, 2016 02:20 PM by mgebhard
Jul 29, 2016 09:15 PM|mandrews1234|LINK
So I want to check the content type and if it's not json or xml, give the user a response saying just that. Now, I know I can do something like
if(request.ContentType.ToLower() != "text/json")
But I feel like there has to be something built in for this, is there? I did some searching but didn't come up with much, although, I may not be using the right combo of words. What's the best way to check if this is xml or json data we're fine, otherwise
Jul 30, 2016 02:20 PM|mgebhard|LINK
Generally you want the client to pick the content-type and the service handle the type seamlessly. Especially, if this is a RESTful service.
There are a many ways to accomplish the takes but it depends on the type of service. For WCF you could code a
message inspector. For ASMX, use an HTTP handler. For WebAPI see this article.