Closed GoogleCodeExporter closed 8 years ago
Original comment by travis.illig
on 17 Apr 2013 at 12:11
I have tested this and it seems to be working, though I did notice an issue
with the doco on the wiki. It shows AsActionFilterFor instead of
AsWebApiActionFilterFor in the example for the registration. The
AsActionFilterFor is for MVC, and AsWebApiActionFilterFor is obviously for Web
API (the same applies for AsWebApiExceptionFilterFor). Also, did you remember
to call builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration)?
Original comment by alex.meyergleaves
on 17 Apr 2013 at 2:06
Hi Alex, thanks for looking at this, yes I have registered the filter provider
and am using the correct extension methods.
With some further investigation it seems that in isolation they work, however
if you register all three types of filter together the Auth and Exception ones
don't fire.
Steps to repro:
1.
Create a new MVC4 Web Api project
2.
Throw an exception from the Get method of the default ValuesController
3.
Install 3.0.0 of the web api bits with: Install-Package Autofac.WebApi -Version
3.0.0
4.
Add a filter of each type with break points in their methods
5.
Hook everything up in global.asax with:
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration);
builder.RegisterType<ActionFilter>().AsWebApiActionFilterFor<ValuesController>().InstancePerApiRequest();
builder.RegisterType<ExceptionFilter>().AsWebApiExceptionFilterFor<ValuesController>().InstancePerApiRequest();
builder.RegisterType<AuthFilter>().AsWebApiAuthorizationFilterFor<ValuesController>().InstancePerApiRequest();
var container = builder.Build();
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
6.
Run the app and hit /api/values and see that each break point is hit
7.
Update Nuget package to latest 3.0.1 web api integration bits
8.
Run the app and see that only break points in the action filter are hit, auth
and exception filters are not
Cheers!
Original comment by sean.bla...@gmail.com
on 18 Apr 2013 at 10:37
This issue was closed by revision 7b1490038e34.
Original comment by alex.meyergleaves
on 19 Apr 2013 at 2:03
Thanks for the extra information Sean. I have fixed issue and pushed a 3.0.2
package to NuGet. Let me know if you have any further troubles.
Original comment by alex.meyergleaves
on 19 Apr 2013 at 2:04
Looks great, thanks again!
Original comment by sean.bla...@gmail.com
on 20 Apr 2013 at 11:59
Original issue reported on code.google.com by
sean.bla...@gmail.com
on 16 Apr 2013 at 1:16