简体   繁体   English

ASP.NET 5-启动ASP.NET vNext项目

[英]ASP.NET 5 - Starting an ASP.NET vNext project

I am trying to get my feet wet with ASP.NET vNext. 我正在尝试使用ASP.NET vNext弄湿我的脚。 I'm very interested in the cross-platform aspect of it. 我对它的跨平台方面非常感兴趣。 For that reason, I'm focused on using the K Runtime Environment. 因此,我专注于使用K运行时环境。

I've looked at the sample provided on the home page . 我看了主页上提供的示例。 Those samples do not help me though. 这些样本对我没有帮助。 I have a project that is structure like this: 我有一个结构如下的项目:

/
 /client
 /server
  /controllers
   HomeController.cs
  /views
   /home
     Index.cshtml
  project.json
  Startup.cs

When I navigate to the directory with project.json, I run the following from the command-line. 当我使用project.json导航到目录时,我从命令行运行以下命令。

C:\MyProject\server>k web

I get the following error: 我收到以下错误:

System.IO.FileLoadException: Could not load file or assembly 'server' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
File name: 'server' ---> Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException: C:\MyProject\server\controllers\HomeController.cs(5,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I feel like Startup.cs is looking for something called server . 我觉得Startup.cs在寻找一种叫做server东西。 Yet it doesn't exist. 但是它不存在。 I suspect something is missing from project.json . 我怀疑project.json缺少某些内容。 However, I do not know what. 但是,我不知道是什么。 My project.json looks like the following: 我的project.json如下所示:

{
    "dependencies": {
        "Kestrel": "1.0.0-beta1",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta1",
        "Microsoft.AspNet.Hosting": "1.0.0-beta1",
        "Microsoft.AspNet.Mvc": "6.0.0-beta1",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1"
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001"
    },
     "frameworks": {
        "aspnet50": {},
        "aspnetcore50": {}
  }
}

What am I doing wrong? 我究竟做错了什么? Thank you! 谢谢!

As Tim has pointed out there's something fishy in your controllers. 正如Tim所指出的那样,您的控制器中有些混乱。

The compiler asks for System.Web but you shouldn't use it. 编译器要求使用System.Web但您不应使用它。 Is it referenced somewhere? 在某处引用了它吗? vNext is moving away from System.Web; vNext正在远离System.Web; we should not use it in MVC 6 . 我们不应该在MVC 6使用它。

Are you using the stock New Project? 您是否正在使用库存的New Project? Are you using the latest CTP/Preview version? 您使用的是最新的CTP /预览版吗?

If you are using the stock New Project just try recreate the project. 如果您使用的是库存新项目,请尝试重新创建该项目。 Yes, I have solved an error in VS 2015 by only recreating the stock project. 是的,通过仅重新创建库存项目,我已经解决了VS 2015中的错误。

I would recommend you to read this article: 我建议您阅读这篇文章:
http://www.dzone.com/articles/developing-and-self-hosting http://www.dzone.com/articles/developing-and-self-hosting

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM