Servicio de aplicaciones de Azure - Autenticación personalizada - Verbo HTTP no permitido
Seguí este tutorial para habilitar la autenticación en mi aplicación Xamarin.Forms:https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/
Una prueba con Postman (como se describe en el tutorial) fue exitosa. La ficha volvió.
Cuando llamo a esto desde mi código C # ...
LoginAsync("custom", Newtonsoft.Json.Linq.JObject.FromObject(auth));
Recibí un error como:
Method not allowed. HTTP Verb not allowed
Descubrí que el SDK de Azure envía una solicitud POST y GET al llamar a LoginAsync. Así que cambié esto ...
[HttpPost, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
a esto...
[HttpPost, HttpGet, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
El error del verbo HTTP desapareció pero se produce el siguiente error:
Operation=ReflectedHttpActionDescriptor.ExecuteAsync, Exception=System.NullReferenceException: Object reference not set to an instance of an object.
at CPM.Arda.Mobile.Freelancer.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext()
2017-07-11T10:39:50 PID[9680] Error Operation=ApiControllerActionInvoker.InvokeActionAsync, Exception=System.NullReferenceException: Object reference not set to an instance of an object.
at CPM.Arda.Mobile.Freelancer.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
Estoy realmente confundido. Ningún tutorial disponible para este tema parece funcionar fuera de la caja.