Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb API ReadFromStreamAsync not executed
    text
    copied!<p>I have a very dumb issue related to a custom formatter.</p> <pre><code>public class RequestHeaderJsonFormatter : MediaTypeFormatter { public RequestHeaderJsonFormatter() { SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/xml")); SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/xml")); SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain")); } public override System.Threading.Tasks.Task&lt;object&gt; ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) { return base.ReadFromStreamAsync(type, readStream, content, formatterLogger); } public override bool CanReadType(Type type) { return true; } public override bool CanWriteType(Type type) { return true; } } </code></pre> <p>I register the formatter in Global.asax as it follows:</p> <p>protected void Application_Start() { GlobalConfiguration.Configuration.Formatters.Insert(0, new RequestHeaderJsonFormatter());</p> <pre><code>AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); </code></pre> <p>}</p> <p>My issue is that ReadFromStreamAsync never gets called when executing the controller action.</p> <pre><code>public class HomeController : ApiController { public HttpResponseMessage GetString(string param) { var response = Request.CreateResponse(HttpStatusCode.OK, "ererrer"); return response; } } </code></pre> <p>What am I doing wrong...I can't figure it out. Any help would be much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload