I have methods like this:
[HttpPost]
public ActionResult Delete(BaseViewModel vm) {
public ActionResult Delete(string ac) {
try {
From within my action filter is there a way that I can check if the method is a post or get ?
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
??
You can check the Request. HttpMethod property.
Action Filter is an attribute that you can apply to a controller action or an entire controller. This filter will be called before and after the action starts executing and after the action has executed. Action filters implement the IActionFilter interface that has two methods OnActionExecuting andOnActionExecuted.
The ActionExecutingContext
has a HttpContext
property. From there, you can obtain the Request
property, which has a HttpMethod
property, which tells you which method was used in this request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With