using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.HttpSys; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace SelfHostServer { public class Startup { public void ConfigureServices(IServiceCollection services) { // Server options can be configured here instead of in Main. services.Configure(options => { options.Authentication.Schemes = AuthenticationSchemes.None; options.Authentication.AllowAnonymous = true; }); } public void Configure(IApplicationBuilder app) { app.Run(async context => { context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello world from " + context.Request.Host + " at " + DateTime.Now); }); } public static void Main(string[] args) { var host = new WebHostBuilder() .ConfigureLogging(factory => factory.AddConsole()) .UseStartup() .UseHttpSys(options => { options.UrlPrefixes.Add("http://localhost:5000"); options.Authentication.Schemes = AuthenticationSchemes.None; options.Authentication.AllowAnonymous = true; }) .Build(); host.Run(); } } }