Asp.net Web Api项目开发笔记

IOC用Autofac,通过所属程序集注册ApiController:

ContainerBuilder builder ;

 builder.RegisterApiControllers(Assemblies);

实例化ApiController:

HttpConfiguration config;

Autofac.IContainer container;

config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

部署Web Api项目时需要修改web.config文件,确保包含节点modules:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />

</system.webServer>

你可能感兴趣的:(Asp.net Web Api项目开发笔记)