During the OnActionExecuting
method, some processing are made which could lead to a redirection to the home page.
But in Ajax POST calls, these processing will definitely fail. Calls are made by a grid from Kendo UI, so I have no control on them.
So I want this method handles in two different ways if calls are GET
and POST
.
I tried :
[HttpGet]
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Do something
}
[HttpPost]
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Do nothing
}
But it does work.
I can't find a Property like IsPostBack
in WebFroms.
The ActionExecutingContext
has a HttpContext
property. From there, you can obtain the Request
property, which has a HttpMethod
property
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if(filterContext.HttpContext.Request.HttpMethod == "POST")
{
// Do nothing
}
else
{
//Do Something
}
}
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