从.NET 4.5迁移到OWIN .NET 4.6.1,找不到HttpConfiguration

时间:2015-12-08 11:03:44

标签: c# .net asp.net-web-api owin .net-4.6.1

我正在重构我的.NET WebAPI项目,从.NET 4.5迁移到最新的4.6.1。

除了HttpConfiguration()之外,其他任何事情似乎都会顺利进行,无法解决:

Error CS0246 The type or namespace name 'HttpConfiguration' could not be found

.NET 4.6.1中的等价类是什么?

我故意避免使用System.Web

我的目标是使用OWIN作为System.Web的替代品,因此我需要找出与HttpConfiguration相当的OWIN

修改

这是代码,如果删除对HttpConfiguration

的每个引用,则System.Web无法解析
   public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            using (var configuration = new HttpConfiguration())
            {
                var container = UnityConfig.Container;

                // var resolver = new UnityHierarchicalDependencyResolver(container);
                var resolver = new UnityDependencyResolver(container);

                configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

                configuration.DependencyResolver = resolver;
                configuration.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional });

                app.UseWebApi(configuration);
            }

            app.UseNancy();
            app.UseStageMarker(PipelineStage.MapHandler);
        }
    }
}

0 个答案:

没有答案