C# Azure应用程序服务-自定义身份验证-不允许使用HTTP谓词
我按照本教程在Xamarin.Forms应用程序中启用身份验证: 与邮递员的测试(如教程中所述)成功进行。令牌返回 当我从我的C代码中调用这个时 我犯了一个错误,比如:C# Azure应用程序服务-自定义身份验证-不允许使用HTTP谓词,c#,.net,azure,xamarin,azure-app-service-envrmnt,C#,.net,Azure,Xamarin,Azure App Service Envrmnt,我按照本教程在Xamarin.Forms应用程序中启用身份验证: 与邮递员的测试(如教程中所述)成功进行。令牌返回 当我从我的C代码中调用这个时 我犯了一个错误,比如: Method not allowed. HTTP Verb not allowed 我发现Azure SDK在调用LoginAsync时发送POST和GET请求。所以我改变了这个 [HttpPost, Route(".auth/login/custom")] public IHttpActionResult
Method not allowed. HTTP Verb not allowed
我发现Azure SDK在调用LoginAsync时发送POST和GET请求。所以我改变了这个
[HttpPost, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
对此
[HttpPost, HttpGet, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
HTTP谓词错误已消失,但出现以下错误:
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)
Operation=ReflectedHttpActionDescriptor.ExecuteAsync,Exception=System.NullReferenceException:对象引用未设置为对象的实例。
在CPM.Arda.Mobile.freeloper.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
在lambda_方法(闭包、对象、对象[])
在System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c\u DisplayClass10.b\u 9(对象实例,对象[]方法参数)
位于System.Web.Http.Controller.ReflectedHttpActionDescriptor.ActionExecutor.Execute(对象实例,对象[]参数)
位于System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext,IDictionary`2参数,CancellationToken CancellationToken)
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Web.Http.Tracing.itraceWriteExtensions.d_u18`1.MoveNext()中
2017-07-11T10:39:50 PID[9680]错误操作=ApiControllerActionInvoker.InvokeActionAsync,异常=System.NullReferenceException:对象引用未设置为对象的实例。
在CPM.Arda.Mobile.freeloper.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
在lambda_方法(闭包、对象、对象[])
在System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c\u DisplayClass10.b\u 9(对象实例,对象[]方法参数)
位于System.Web.Http.Controller.ReflectedHttpActionDescriptor.ActionExecutor.Execute(对象实例,对象[]参数)
位于System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext,IDictionary`2参数,CancellationToken CancellationToken)
我真的很困惑。本主题没有现成的教程
我发现Azure SDK在调用LoginAsync时发送POST和GET请求
好的,移动应用后端将强制使用https,如果您使用httphttp
发送请求,则您将获得302状态码,如下所示:
如上所述,从http->https重定向会导致http谓词获取
使用Https更改移动应用Uri当您初始化MobileServiceClient
时,您的代码将按预期工作
这看起来像控制器操作中发生的NullReferenceException。
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)