以编程方式运行自托管的asp.net 5 app

时间:2015-08-17 15:16:53

标签: asp.net console-application asp.net-core self-hosting

我能够使用添加到project.json的命令创建并运行自托管的asp.net应用程序: “Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000

可以在与控制台应用程序相同的过程中以编程方式运行asp.net应用程序吗?

我试过了

WebApp.Start<Startup>("http://localhost:5000/");

但编译器返回错误:

  

错误CS0234类型或命名空间名称'Owin'不存在于   命名空间'Microsoft'(你错过了一个程序集   参考?)AspNetConsolApp.DNX Core 5.0

     

CS0103当前上下文AspNetConsolApp.DNX Core 5.0中不存在名称“WebApp”

我当前的project.json:

  "dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "System.Diagnostics.Tools": "4.0.0-beta-23109",
     "Microsoft.Owin.Hosting": "2.0.2"
  },

  "commands": {
    "AspNetConsolApp": "AspNetConsolApp",
    "Web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
  },

  "frameworks": {
    "dnx451": {
      "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
      "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
      "Microsoft.Owin.Hosting": "2.0.2",
      "dependencies": {
        "Microsoft.Owin.Hosting": "2.0.2"

      }
    },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
        "System.Diagnostics.Tools": "4.0.0-beta-23109",
        "System.Collections": "4.0.10-beta-23019",
        "System.Console": "4.0.0-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019"
      }
    }

0 个答案:

没有答案