No MediaTypeFormatter is available to read after deployment to prod
asp.net-mvc, asp.net-web-api, c#
Solution
This message indicates that you are trying to deserialize an instance of `Business` from a message that does not specify the `Content-Type` header. In such a case Web API does not know how to deserialize the message (it doesn't know if it's xml or json, for example). Are you sure that the service that is being called on the server is returning a correctly annotated message? (you can check the value of the service.Headers.ContentType property).
Problem
I have a webapi project mvc4 rc and a mvc4 rc web application deployed on a server. Locally everything works correctly however on the server I get an error 2012-06-09 03:18:18,659 [23] INFO WebApplication.Controllers.AccountController – System.InvalidOperationException: No MediaTypeFormatter is available to read an object of type 'Business' from content with media type ''undefined''. at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger) at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, IEnumerable`1 formatters) at WebApplication.Repository.BusinessRepository.GetByUserId(Guid userId) in C:\@Code\WebApplication\Repository\BusinessRepository.cs:line 37 at WebApplication.Controllers.AccountController.SignIn(LogOnModel model, String returnUrl) in C:\@Code\WebApplication\Controllers\AccountController.cs:line 61 . My code that is trying to call the service looks like ``` var url = ApiRestHelper.ApiUrl(ApiEndPointConstants.GetBusinessByUserId, "userId", userId.ToString()); var service = ApiRestHelper.Get(url).Content; var data = service.ReadAsAsync<Business>().Result; HttpContext.Current.Session["BusinessInfo"] = data; return data; public static HttpResponseMessage Get(string apiMethod, string baseAddress) { var myHttpClient = new System.Net.Http.HttpClient { BaseAddress = new Uri(baseAddress) }; var get = myHttpClient.GetAsync(apiMethod); var x = get.Result; return x; } ``` What am I doing wrong?