类型或命名空间名称Web在命名空间系统中不存在

Dud*_*ord 3 c# asp.net-core

我一直在使用.NET Core 1.0.1.我只想尝试启动并运行Hello World页面.在构建期间,我遇到了以下错误:

The type or namespace name 'Web' does not exist in the namespace 'System' (are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我尝试添加对project.json的引用:

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "System.Web": "4.0.0" //Right here
  }
Run Code Online (Sandbox Code Playgroud)

但我得到错误:The dependency System.Web >= 4.0.0 could not be resolved.我似乎无法像在C#console/dll库中那样正常添加引用.

我需要安装另一个实际包含system.web程序集的软件包吗?或者有没有办法手动添加此引用?

Hen*_*ema 6

在.NET Core中,特别是ASP.NET Core,再也没有 System.Web了.所有ASP.NET组件都位于Microsoft.AspNetCore.*Microsoft.Extensions.*名称空间中.

例如,HttpContext住在Microsoft.AspNetCore.HttpControllerMicrosoft.AspNetCore.Mvc.

我建议你阅读ASP.NET Core基础知识.