You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So instead of doing reflection in the SetHttpResponseStatusCode method, you could do this:
publicstaticasyncTaskSetHttpResponseStatusCode(thisFunctionContextcontext,HttpStatusCodestatusCode){varhttpResponse=(awaitcontext.GetHttpRequestDataAsync()).CreateResponse(statusCode);varhttpOutputBindingFromMultipleOutputBindings=context.GetOutputBindings<HttpResponseData>().FirstOrDefault(b =>b.BindingType=="http"&&b.Name!="$return");if(httpOutputBindingFromMultipleOutputBindingsis not null){httpOutputBindingFromMultipleOutputBindings.Value=httpResponse;}else{varinvocationResult=context.GetInvocationResult();invocationResult.Value=httpResponse;}}
The text was updated successfully, but these errors were encountered:
Thanks for the example project!
To anyone wondering, if there's a better way of setting the response code on the HTTP response if a 401 or 403 happens:
Microsoft published a sample middleware doing just that https://github.com/Azure/azure-functions-dotnet-worker/blob/a5fc0632d233b242debfd1485e527315567b9b3a/samples/CustomMiddleware/ExceptionHandlingMiddleware.cs#L47-L58
You just need to update to the latest function worker package.
My version is:
So instead of doing reflection in the
SetHttpResponseStatusCode
method, you could do this:The text was updated successfully, but these errors were encountered: