ddllll

ddllll

  • NA
  • 2
  • 549

How to catch a result from IActionFilter?

Jan 22 2023 5:26 PM

I'm new to c# and .net in general (not to programming at all) and i have one small question about filter attributes in c#

Consider having filter with type of IActionFilter like this:

My question is how could i catch this context.Result property to use it like a return type? For example, i have a controller method that should normally return (for example) response 200, but under some exceptions that can be handled inside my filter, the filter itself could return 404. So back to the equestion, is it possible to catch this context.Result? And if so, what is the best practives to do it?


Answers (3)