Skip to content

Instantly share code, notes, and snippets.

@agehlot
Created September 30, 2022 11:46
Show Gist options
  • Save agehlot/85ee3ca7990c0c11c26b739606f9c618 to your computer and use it in GitHub Desktop.
Save agehlot/85ee3ca7990c0c11c26b739606f9c618 to your computer and use it in GitHub Desktop.
Disable other methods except get and post in the inbound request
<on-error>
<base />
<choose>
<when condition="@(context.Request.Method != "GET" && context.Request.Method != "POST")">
<return-response>
<set-status code="405" reason="Method not allowed" />
<set-body>@{
return new JObject(
new JProperty("status", "HTTP 405"),
new JProperty("message", "Method not allowed")
).ToString();
}</set-body>
</return-response>
</when>
<otherwise />
</choose>
</on-error>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment