title: Read JSON post data in ASP.Net Core MVC
body: <p>I've tried to find a solution for this, but all the ones coming up are for previous versions of ASP.Net.</p>
  
  <p>I'm working with the JWT authentication middleware and have the following method:</p>
  
  <pre><code>private async Task GenerateToken(HttpContext context)
  {
      var username = context.Request.Form["username"];
      var password = context.Request.Form["password"];
      //Remainder of login code
  }
  </code></pre>
  
  <p>This gets the sent data as if it was form data, but my Angular 2 front end is sending the data as JSON.</p>
  
  <pre><code>login(username: string, password: string): Observable&lt;boolean&gt; {
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers });
      let body = JSON.stringify({ username: username, password: password });
          return this.http.post(this._api.apiUrl + 'token', body, options)
              .map((response: Response) =&gt; {
                  
              });
      }
  </code></pre>
  
  <p>My preferred solution is to send it as JSON, but I've been unsuccessful in retrieving the data.  I know it's sending, because I can see it in fiddler, and if I use Postman and just send form data it works fine.</p>
  
  <p>Basically I just need to figure out how to change this line to read the json data</p>
  
  <pre><code>var username = context.Request.Form["username"];
  </code></pre>