【发布时间】:2018-11-12 13:41:52
【问题描述】:
我正在尝试使用Kestrel 而不是IIS 托管.NET Core 应用程序。我似乎收到以下错误:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.AspNetCore.Server.IISIntegration, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'
杂项
class Address {
public string ProtocolType { get; set; } = "http";
public string Host { get; set; }
public long Port { get; set; }
public static Address Default = new Address { Host = "localhost", Port = 9300, ProtocolType = "http" };
}
static class AddressExtensions {
public static string ToUrl(this Address @this) {
return $"{@this.ProtocolType}//{@this.Host}:{@this.Port}";
}
}
计划
public class Program {
public static void Main(string[] args) {
CreateWebHostBuilder(args).Build().Start();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) {
var builder=WebHost.CreateDefaultBuilder(args); //crashes here !!
builder.UseStartup("Startup");
var url = Address.Default.ToUrl();
builder.UseKestrel().UseUrls(url);
return builder;
}
}
启动
public class Startup {
public void ConfigureServices(IServiceCollection services) {
services.AddMvcCore();
}
public void Configure(IApplicationBuilder app) {
app.Map("/http", x => x.UseMvc());
app.Map("/ws", x => {
});
app.UseMvc();
}
}
为什么它会尝试将其托管在 IIS 上?我必须指定我没有launchSettings.json 文件。它没有从.NET Core App 模板创建一个。我是否必须手动执行才能在IIS 之外运行?
我怎样才能让这个服务器在IIS之外工作和运行?
【问题讨论】:
标签: asp.net-core hosting kestrel