2014-06-17 01:24:20 +04:00
|
|
|
using System;
|
2016-01-22 23:23:36 +03:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2016-12-15 23:46:16 +03:00
|
|
|
using Microsoft.AspNetCore.Server.HttpSys;
|
2016-04-18 23:04:05 +03:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2015-10-04 01:44:44 +03:00
|
|
|
using Microsoft.Extensions.Logging;
|
2014-04-01 00:05:03 +04:00
|
|
|
|
|
|
|
namespace SelfHostServer
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
2016-04-18 23:04:05 +03:00
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
// Server options can be configured here instead of in Main.
|
2016-12-16 01:38:59 +03:00
|
|
|
services.Configure<HttpSysOptions>(options =>
|
2016-04-18 23:04:05 +03:00
|
|
|
{
|
2016-12-16 01:38:59 +03:00
|
|
|
options.Authentication.Schemes = AuthenticationSchemes.None;
|
|
|
|
options.Authentication.AllowAnonymous = true;
|
2016-04-18 23:04:05 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-05 22:42:01 +03:00
|
|
|
public void Configure(IApplicationBuilder app)
|
2014-04-01 00:05:03 +04:00
|
|
|
{
|
|
|
|
app.Run(async context =>
|
|
|
|
{
|
2017-01-11 23:00:19 +03:00
|
|
|
context.Response.ContentType = "text/plain";
|
|
|
|
await context.Response.WriteAsync("Hello world from " + context.Request.Host + " at " + DateTime.Now);
|
2014-04-01 00:05:03 +04:00
|
|
|
});
|
|
|
|
}
|
2015-12-18 03:47:55 +03:00
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
{
|
2016-01-18 02:58:30 +03:00
|
|
|
var host = new WebHostBuilder()
|
2017-05-05 22:42:01 +03:00
|
|
|
.ConfigureLogging(factory => factory.AddConsole())
|
2015-12-18 03:47:55 +03:00
|
|
|
.UseStartup<Startup>()
|
2016-12-16 01:38:59 +03:00
|
|
|
.UseHttpSys(options =>
|
2016-04-16 02:08:54 +03:00
|
|
|
{
|
2017-02-28 06:40:38 +03:00
|
|
|
options.UrlPrefixes.Add("http://localhost:5000");
|
2016-12-16 01:38:59 +03:00
|
|
|
options.Authentication.Schemes = AuthenticationSchemes.None;
|
|
|
|
options.Authentication.AllowAnonymous = true;
|
2016-04-16 02:08:54 +03:00
|
|
|
})
|
2015-12-18 03:47:55 +03:00
|
|
|
.Build();
|
|
|
|
|
2016-01-18 02:58:30 +03:00
|
|
|
host.Run();
|
2015-12-18 03:47:55 +03:00
|
|
|
}
|
2014-04-01 00:05:03 +04:00
|
|
|
}
|
|
|
|
}
|