我正在重构我的.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);
}
}
}