如何在dotnet核心应用程序中自动从iis启动kestrel服务器

时间:2016-08-17 19:19:03

标签: asp.net-core iis-7.5 kestrel-http-server

我有一个dotnet核心应用程序,我可以在IIS后面工作:80个请求,但我需要直接在6001上访问kestrel,因为我的IIS不支持websockets。我可以从服务器运行exe,它将启动一个cmd窗口并监听6001,但它不能保持可靠。是否有可能让它自动启动并保持6001?

这是我的创业公司

{
  "dependencies": {

    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Binder": "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.AspNetCore.Websockets.Server": "0.1.0",
    "Swashbuckle": "6.0.0-beta901",
    "AutoMapper": "5.0.2"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "runtimes": {
    "win7-x64": {}
  },

  "commands": {
    "run": "run server.urls=http://localhost:6001",
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:6001",
    "weblistener": "Microsoft.AspNet.Hosting --server WebListener --server.urls http://localhost:6001"
  }, 
  "publishOptions": {
    "include": [
      "wwwroot",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

这是我的proj文件

{{1}}

1 个答案:

答案 0 :(得分:0)

如果仅由于websocket而将其作为EXE运行,则 您可以使用IIS URL重写来检测流量,如果是websocket,请对其进行升级,然后将其传递给Kestrel和您的应用程序。

看看here