I've setup a custom filter inside an umbraco installation in this way:
1) inside global.asax
public class Global : UmbracoApplication{
protected override void OnApplicationStarting(object sender, EventArgs e) {
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
base.OnApplicationStarting(sender, e);
}
}
2) inside App_start/FilterConfig.cs
public static void RegisterGlobalFilters(GlobalFilterCollection filters){
filters.Add(new CheckFilterAttribute());
}
3) inside Filters/CheckFilterAttribute.cs
public class CheckFilterAttribute : ActionFilterAttribute {
public override void OnActionExecuting(ActionExecutingContext filterContext) {
var dateTemp= DateTime.Now;
}
}
and it's works (i've set a breakpoint on var dateTemp= DateTime.Now; and application stop at every request on that breakpoint correctly.
My question is: there's a way inside a filter to access to Umbraco data?
Something like
DynamicPublishedContentList list = Umbraco.ContentAtXPath("//name", null);
MVC Filter inside Umbraco 6/7
Hi
I've setup a custom filter inside an umbraco installation in this way:
1) inside global.asax
2) inside App_start/FilterConfig.cs
3) inside Filters/CheckFilterAttribute.cs
and it's works (i've set a breakpoint on var dateTemp= DateTime.Now; and application stop at every request on that breakpoint correctly.
My question is: there's a way inside a filter to access to Umbraco data? Something like
in the same way like in a view?
thanks a lot
You can do this in your filter:
Than you can get the current node like this:
Jeroen
just happened across this and it's dug me out of a hole!
appreciate that the post is nearly 4 years old but big thanks jeroen ;)
thanks a lot Jeroen
Hello,
Could you please mark a post as the solution if it helped you.
Jeroen
is working on a reply...