ASP.NET Core Cannot Read Request Body
<p>I have been working on ASP.NET Core from a few weeks. I was trying to achieve something based on this blog:
<a href="https://auth0.com/blog/2015/09/04/an-introduction-to-microservices-part-1/">Microservices</a></p>

<p>My <code>project.json</code> is as follows:</p>

<pre><code>{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {

    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-*",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.Formatters.Json": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-rc1-final",
    "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516"

  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {

    "dnxcore50": {
      "dependencies": {


      }

    }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}
</code></pre>

<p>And <code>ConfigureServices</code> method in <code>Startup.cs</code> is as follows:</p>

<pre><code>public void ConfigureServices(IServiceCollection services)
{
    //Registering Authorization Database
    AutorizationAccessRegisteration.RegisterComponents(services, Configuration);

    services.AddMvcCore()
        .AddJsonFormatters(a =&gt; a.ContractResolver = new CamelCasePropertyNamesContractResolver());

    //Add cors built in support.
    services.AddCors();

    services.AddMvcCore().AddApiExplorer();

    //Add MVC for supporting WebApi requests
    #region MVC Add

    services.AddMvc();

    services.AddMvc().AddMvcOptions(options =&gt;
    {
        options.RespectBrowserAcceptHeader = true;

        // Input Formatters.
        options.InputFormatters.Clear();

        var jsonInputFormatter = new JsonInputFormatter()
        {
            SerializerSettings = new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
                ,
                DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
                NullValueHandling = NullValueHandling.Ignore
            }
        };


        options.InputFormatters.Add(jsonInputFormatter);

        //Output formater
        //as part of get/post request, set the header Accept = application/json or application/xml
        var jsonOutputFormatter = new JsonOutputFormatter();
        jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        jsonOutputFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore;
        options.OutputFormatters.Insert(0, jsonOutputFormatter);

        options.OutputFormatters.Insert(1, new XmlDataContractSerializerOutputFormatter());

    });

    #endregion
}
</code></pre>

<p>And here is my <code>Confiure</code> method in Startup.cs:</p>

<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {

    }
    else if (env.IsStaging())
    {

    }
    else if (env.IsProduction())
    {

    }

    app.UseIISPlatformHandler();

    app.UseCors(builder =&gt;
            builder.WithOrigins("*").AllowAnyHeader().AllowAnyMethod());

    //Middlewares addition to the pipelines:
    /// We add the middlewares in the following fashion:
    /// - Exception Handler
    /// - Logger
    /// - Authorization Handler
    /// There is a big reason of doing that.
    ///
    app.UseExceptionHandler();
    app.UseLoggerHandler();
    app.UseAuthorizationHandler();

    app.UseMvc();
}
</code></pre>

<p>An AuthorizationController is as follows:</p>

<pre><code>[Route("api/Authorization")]
public class AuthorizationController : Controller
{
 .
     [HttpPost]
     public void Post([FromBody]string value)
     {
     }
 .
}
</code></pre>

<p>The <code>Post</code> method originally had <code>[FromBody]string[] value</code>. I simplified it further by making it a simple <code>string</code> type. I am using Advance Rest Client on Chrome to send an <code>HTTP request</code>. When <code>string[]</code> was the type I was the following values in body:</p>

<pre><code>{

  ["value","sdjklgsdjlg"]

}
</code></pre>

<p>After simplifying the parameter, I tried sending request with the following body:</p>

<pre><code>{"sdjklgsdjlg"}
</code></pre>

<p>tried this as well:</p>

<pre><code>{"value":"sdjklgsdjlg"}
</code></pre>

<p>Am I missing something? I read before, the way old WebApi used to work in relation to the JSON mapping to the complex objects and normal parameters, it works in similar fashion in .NET Core.</p>

<p>Also I should elaborate that <em>breakpoint</em> is hit normally on all the middlewares and controllers. But none of the middleware seems to be able to read Request's stream related things:</p>

<p><a href="https://i.stack.imgur.com/yGBVf.jpg"><img src="https://i.stack.imgur.com/yGBVf.jpg" alt="context.Request variable problems"></a></p>

<p><a href="https://i.stack.imgur.com/RSVZh.jpg"><img src="https://i.stack.imgur.com/RSVZh.jpg" alt="context.Request.Body errors"></a></p>

<p>Kindly tell me where I am making problem. Thanks a lot!</p>