public class VerificationAttribute : ActionFilterAttribute
{
public VerificationAttribute ()
{
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//We don't care about children/partials
if (filterContext.IsChildAction)
return;
}
MVC ActionFilterAttribute but only on main View
-
14-06-2023 - |
Pregunta
I have an attribute on my Controller
[ABC]
MyController
The Attribute checks something but I only want to check once per page.
public class ABCAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
////Do some check
}
The OnActionExecuting fires for every element on the page. Partials etc.
How do I check to see if the filterContext is the main page and not a child resource on the page?
Solución
Otros consejos
Ignore, think I miss read your question
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow