Adapt samples to .NET Core.
This commit is contained in:
parent
f11c5aef23
commit
86af69d2d7
|
|
@ -9,7 +9,12 @@ namespace HelloWorld
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Run(args).Wait();
|
||||
}
|
||||
|
||||
public static async Task Run(string[] args)
|
||||
{
|
||||
using (WebListener listener = new WebListener())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
{
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.Net.Http.Server": "0.1.0-*",
|
||||
"Microsoft.Net.WebSockets.Server": "0.1.0-*",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-*"
|
||||
"Microsoft.Net.WebSockets.Server": "0.1.0-*"
|
||||
},
|
||||
"commands": {
|
||||
"sample": "HelloWorld"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"net451": {},
|
||||
"netstandardapp1.5": {
|
||||
"dependencies": {
|
||||
"System.Collections": "4.0.11-*",
|
||||
"System.Console": "4.0.0-*",
|
||||
"System.Globalization": "4.0.11-*",
|
||||
"System.IO": "4.1.0-*",
|
||||
"System.Threading.Tasks": "4.0.11-*"
|
||||
"NETStandard.Library": "1.0.0-*"
|
||||
},
|
||||
"imports": [
|
||||
"dnxcore50"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Server.Features;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Net.Http.Server;
|
||||
|
||||
namespace HotAddSample
|
||||
{
|
||||
|
|
@ -17,7 +18,7 @@ namespace HotAddSample
|
|||
{
|
||||
loggerfactory.AddConsole(LogLevel.Information);
|
||||
|
||||
var addresses = app.ServerFeatures.Get<IServerAddressesFeature>().Addresses;
|
||||
var addresses = app.ServerFeatures.Get<WebListener>().UrlPrefixes;
|
||||
addresses.Add("http://localhost:12346/pathBase/");
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
|
|
@ -31,7 +32,7 @@ namespace HotAddSample
|
|||
try
|
||||
{
|
||||
addresses.Add(toAdd);
|
||||
await context.Response.WriteAsync("Added: " + toAdd);
|
||||
await context.Response.WriteAsync("Added: <a href=\"" + toAdd + "\">" + toAdd + "</a>");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -93,6 +94,7 @@ namespace HotAddSample
|
|||
var host = new WebHostBuilder()
|
||||
.UseDefaultConfiguration(args)
|
||||
.UseStartup<Startup>()
|
||||
.UseServer("Microsoft.AspNetCore.Server.WebListener")
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"server": "Microsoft.AspNetCore.Server.WebListener",
|
||||
"server.urls": "http://localhost:12345"
|
||||
}
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Server.WebListener": "0.1.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-*"
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
|
|
@ -12,8 +11,11 @@
|
|||
"web": "HotAddSample"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"net451": {},
|
||||
"netstandardapp1.5": {
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-*"
|
||||
},
|
||||
"imports": [
|
||||
"dnxcore50"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ namespace SelfHostServer
|
|||
var host = new WebHostBuilder()
|
||||
.UseDefaultConfiguration(args)
|
||||
.UseStartup<Startup>()
|
||||
.UseServer("Microsoft.AspNetCore.Server.WebListener")
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"server": "Microsoft.AspNetCore.Server.WebListener",
|
||||
"server.urls": "http://localhost:8080"
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Server.WebListener": "0.1.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-*"
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
|
|
@ -11,8 +10,11 @@
|
|||
"web": "SelfHostServer"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"net451": {},
|
||||
"netstandardapp1.5": {
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-*"
|
||||
},
|
||||
"imports": [
|
||||
"dnxcore50"
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue