I am creating some middleware in my query pipeline that will generate a JWT bearer token if the submitted form data is valid (connected to AspNetCore.Identity).
Based on the great Nate Barbettini tutorial:
https://stormpath.com/blog/token-authentication-asp-net-core
I ran into a problem when the HttpContext is available in my new middleware, throws exceptions trying to access context.Reqeust.Form ["myfieldname"]
I use postman to submit form data using: Content-Type: application / x-www-form-urlencoded
I can debug my middleware and check the context. Request.Form I see this:
Form = '((Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest)((Microsoft.AspNetCore.Http.DefaultHttpContext)context).Request).Form' threw an exception of type 'System.MissingMethodException'
If I go to Content-Type: multipart / form-data, I see this error:
Form = '((Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest)((Microsoft.AspNetCore.Http.DefaultHttpContext)context).Request).Form' threw an exception of type 'System.IO.InvalidDataException'
It is worth noting that I am using the RC2 version of Core: 1.0.0-rc2-3002702 Api works fine with all the verbs Http, POST, PUT, GET, DELETE, I can send and receive data without problems.
I can’t understand why this is happening, or maybe I am missing a fundamental configuration? The current configuration is pretty standard, like out of the box from the VS 2015 templates.
Could this be an RC2 error?
source
share