带有MVC iapplicationbuilder的ASP.NET Core不包含usemvc

时间:2016-10-05 04:19:14

标签: asp.net-core .net-core

在VS Code中构建.net核心mvc应用程序并获取错误IApplicationBuilder不包含UseMvc的定义。这是我在project.json中的依赖项:

"dependencies": {
"Microsoft.NETCore.App": {
  "version": "1.0.1",
  "type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0"

}

2 个答案:

答案 0 :(得分:2)

看起来像是一个愚蠢的依赖。尝试更改此内容:

"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",

到此:

"Microsoft.AspNetCore.Mvc": "1.0.1",

答案 1 :(得分:-1)

将此PropertyGroup添加到projectName.csproj文件:

<PropertyGroup>
   <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;
   </PackageTargetFallback>
</PropertyGroup>

然后关闭解决方案并重新打开。