我为 Katana 中托管的 WebAPI 尝试了 Unity 3。
我收到一个异常,即 system.web.http 无法在启动时加载。
有人做过这个工作吗?
HttpConfiguration apiConfig = new HttpConfiguration();
apiConfig.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
apiConfig.Formatters.Remove(apiConfig.Formatters.XmlFormatter);
apiConfig.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
apiConfig.DependencyResolver = new UnityDependencyResolver(_container);
app.UseWebApi(apiConfig);