-
-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to automatically ignore childaction in .net mvc #554
Comments
Are you using MVC 5? |
Yes, I'm using MVC5. |
Yes, it's a bug when you set up the The MVC 5 engine will call the Action Filter method You can see the issue described here:
A workaround could be to mark with I still need to think a little bit more about this, but I guess another solution could be to provide a new configuration parameter to the attribute like In the meantime, the same effect can be achieved by creating a custom attribute that inherits from AuditAttribute and avoid the auditing by checking the IsChildAction property: public class AuditNoChildAttribute : AuditAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!filterContext.IsChildAction)
base.OnActionExecuting(filterContext);
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (!filterContext.IsChildAction)
base.OnActionExecuted(filterContext);
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
if(!filterContext.IsChildAction)
base.OnResultExecuted(filterContext);
}
} So then you can use |
[Audit(IncludeChildActions = false)]
public class YourController : Controller
{
} |
Thanks, and it looks working great! |
This solution works fine when I get response from action like "Index". But it will be not that right when I call "POST" request from my partial view to refresh part of data even if having set the attribute on controller. |
But AuditIgnore should work in that case, right? |
Yes, absolutely. |
Did you try with AuditIgnore and is not working? |
AuditIgnore works well. |
Describe the bug
If I call @Html.Action("GridView") as a child action to render dynamic content in my razor view, AuditAction.ActionName will be replaced with child action name not the real action name like "Index" thing.
Is this a bug or something? By labeling "GridView" child action as AuditIgnore
Expected behavior
Ignore child action automatically.
Libraries (specify the Audit.NET extensions being used including version):
For example:
Target .NET framework:
The text was updated successfully, but these errors were encountered: