Error with FluentFilters.dll

Jun 28, 2012 at 11:15 PM

Hi, I'm trying use Fluent Filters in my MVC2 proyect, but when I run it appears the error bellow:

The controller for path '/favicon.ico' could not be found or it does not implement IController.

I only put this code in my Global.asax.cs file:

        private static void RegisterFluentFilters()
        {
            FluentFiltersBuilder.Current.Add<AuthorizeAttribute>(c =>
            {
                c.Exclude(new ControllerFilterCriteria("Account"));
            });

            
        }

        private static void RegisterControllerFactory()
        {
            // Set controller factory
            ControllerBuilder.Current.SetControllerFactory(new FluentFiltersControllerFactory());
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            RegisterFluentFilters(); 
            
            RegisterControllerFactory();
        }

I need that only authenticated user can access to my application, because of that I want implement a filterAuthorize that exclude two acctions of the authorization.

Coordinator
Jun 29, 2012 at 12:04 AM
Edited Jun 29, 2012 at 12:05 AM

I have checked and all works fine for me. May be it's problem in your application? Can you provide sample application? Also, please check that you using the latest version of FluentFilters.dll for ASP.NET MVC 2, it's located in the bin/mvc2 folder.

Just in case please try insert next code in the RegisterRoutes method and run application:

routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});
Jun 29, 2012 at 2:17 PM

Thanks, I have inserted the code in the RegisterRoutes and all works fine.

But I have one doubt, I only want exclude LogOn and ChangeCulture Actions in the AccountController. Firstly, I put next code but all Actions in the AccountController are exluded:

        private static void RegisterFluentFilters()
        {
            FluentFiltersBuilder.Current.Add<AuthorizeAttribute>(c =>
            {
                c.Exclude(new ControllerFilterCriteria("Account"));
            });

            
        }

I try use ActionFilterCriteria but isn't works:

        private static void RegisterFluentFilters()
        {
            FluentFiltersBuilder.Current.Add<AuthorizeAttribute>(c =>
            {
                c.Exclude(new ActionFilterCriteria("LogOn")).And(new ActionFilterCriteria("ChangeCulture"));
            });

            
        }

How I should use ActionFilterCriteria to only excludedLogOn and ChangeCulture Actions?

 

Coordinator
Jun 29, 2012 at 2:38 PM

Please try the next definition:

private static void RegisterFluentFilters()
{
    FluentFiltersBuilder.Current.Add<AuthorizeAttribute>(c =>
    {
        c.Exclude(new ActionFilterCriteria("LogOn")).Or(new ActionFilterCriteria("ChangeCulture"));
    });
}

Its means, applying AuthorizeAttribute for all application, excluding LogOn OR ChangeCulture actions.
Please try and let me know if you have any questions.

Jun 29, 2012 at 7:46 PM

Thanks so much, now all works fine. Excelent dll

Coordinator
Jun 29, 2012 at 7:54 PM

You are welcome. I'm glad that my library was useful for you. Thank you for using it. =)

Jun 29, 2012 at 8:08 PM

Thanks so much, now all works fine. Excelent dll