title: Change HTTP PUT Request to HTTP PATCH Request using IAsyncActionFilter and rewrite the whole ActionDescriptor in Asp.net Core
body: <p>I am currently converting from Asp.Net Framework to Core and working on finding a way to change an HTTP PUT/POST request to PATCH when the Content-Type = &quot;application/json-patch+json&quot;. Changing the Method itself is NOT working. I think rewriting the whole ActionDescriptor will do the trick but I have no idea how to do it Below is the code I currently have.</p>
  <pre><code>public class FewzionActionSelector : IAsyncActionFilter {
      public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) {
          // Execute the rest of the MVC filter pipeline
          if (context.HttpContext.Request.ContentType != null &amp;&amp; context.HttpContext.Request.ContentType.Equals(&quot;application/json-patch+json&quot;))
          {
              if (context.HttpContext.Request.Method.Equals(HttpMethod.Put.Method) || context.HttpContext.Request.Method.Equals(HttpMethod.Post.Method))
              {
                  context.HttpContext.Request.Method = $&quot;{HttpMethod.Patch.Method}&quot;;
                  if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor)
                  {
                      var actionAttributes = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true);
  
                  }
              }
          }
          await next();
      }
  }
  </code></pre>