From a9296a6dfd346d9a377fc21c82a4146ac278b703 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 18 Mar 2018 13:10:24 +0200 Subject: [PATCH 1/2] AspnetCore 2.0 sample --- .../HomeModule.cs | 10 ++++++ .../Nancy.Demo.Hosting.AspnetCore.csproj | 16 ++++++++++ .../Nancy.Demo.Hosting.AspnetCore/Program.cs | 15 +++++++++ .../Properties/launchSettings.json | 27 ++++++++++++++++ .../Nancy.Demo.Hosting.AspnetCore/Startup.cs | 31 +++++++++++++++++++ .../Nancy.Demo.Hosting.AspnetCore/global.json | 5 +++ 6 files changed, 104 insertions(+) create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/HomeModule.cs create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/Nancy.Demo.Hosting.AspnetCore.csproj create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/Program.cs create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/Properties/launchSettings.json create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs create mode 100644 samples/Nancy.Demo.Hosting.AspnetCore/global.json diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/HomeModule.cs b/samples/Nancy.Demo.Hosting.AspnetCore/HomeModule.cs new file mode 100644 index 0000000000..1074534447 --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/HomeModule.cs @@ -0,0 +1,10 @@ +namespace Nancy.Demo.Hosting.AspnetCore +{ + public class HomeModule : NancyModule + { + public HomeModule() + { + Get("/", args => "ASP.NET Core hosted Nancy"); + } + } +} \ No newline at end of file diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Nancy.Demo.Hosting.AspnetCore.csproj b/samples/Nancy.Demo.Hosting.AspnetCore/Nancy.Demo.Hosting.AspnetCore.csproj new file mode 100644 index 0000000000..4bb0c413e2 --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Nancy.Demo.Hosting.AspnetCore.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp2.0 + + + + + + + + + + + + diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs b/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs new file mode 100644 index 0000000000..c10d85acb2 --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace Nancy.Demo.Hosting.AspnetCore +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup().Build(); + } +} diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Properties/launchSettings.json b/samples/Nancy.Demo.Hosting.AspnetCore/Properties/launchSettings.json new file mode 100644 index 0000000000..f9d95f849c --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63159/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Nancy.Demo.Hosting.Aspnet": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:63160/" + } + } +} diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs b/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs new file mode 100644 index 0000000000..53e485b2ab --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Nancy.Owin; + +namespace Nancy.Demo.Hosting.AspnetCore +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseOwin().UseNancy(); + + app.Run(async (context) => + { + await context.Response.WriteAsync("Hello World!"); + }); + } + } +} diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/global.json b/samples/Nancy.Demo.Hosting.AspnetCore/global.json new file mode 100644 index 0000000000..70b09f851e --- /dev/null +++ b/samples/Nancy.Demo.Hosting.AspnetCore/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.0.5" + } +} From a57a20059da6c237e4e04504e937e864a3ada593 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 9 May 2018 18:07:28 +0200 Subject: [PATCH 2/2] AspnetCore 2.0 sample Pull request amendments. --- .../Nancy.Demo.Hosting.AspnetCore/Program.cs | 8 +++--- .../Nancy.Demo.Hosting.AspnetCore/Startup.cs | 26 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs b/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs index c10d85acb2..c40180f60c 100644 --- a/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Program.cs @@ -1,8 +1,8 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; - -namespace Nancy.Demo.Hosting.AspnetCore +namespace Nancy.Demo.Hosting.AspnetCore { + using Microsoft.AspNetCore; + using Microsoft.AspNetCore.Hosting; + public class Program { public static void Main(string[] args) diff --git a/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs b/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs index 53e485b2ab..1fefcae06a 100644 --- a/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs +++ b/samples/Nancy.Demo.Hosting.AspnetCore/Startup.cs @@ -1,11 +1,10 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Nancy.Owin; - -namespace Nancy.Demo.Hosting.AspnetCore +namespace Nancy.Demo.Hosting.AspnetCore { + using Microsoft.AspNetCore.Builder; + using Microsoft.AspNetCore.Hosting; + using Microsoft.Extensions.DependencyInjection; + using Nancy.Owin; + public class Startup { // This method gets called by the runtime. Use this method to add services to the container. @@ -17,15 +16,12 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - if (env.IsDevelopment()) - app.UseDeveloperExceptionPage(); - - app.UseOwin().UseNancy(); - - app.Run(async (context) => + if (env.IsDevelopment()) { - await context.Response.WriteAsync("Hello World!"); - }); + app.UseDeveloperExceptionPage(); + } + + app.UseOwin().UseNancy(); } } }