diff --git a/build/common.props b/build/common.props
index 6a1fb41..814ece1 100644
--- a/build/common.props
+++ b/build/common.props
@@ -40,6 +40,7 @@
+
@@ -149,7 +150,6 @@
-
diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs
index 30ba926..9e3da42 100644
--- a/samples/SampleApp/Program.cs
+++ b/samples/SampleApp/Program.cs
@@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Threading.Tasks;
using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
@@ -19,6 +21,8 @@ public static void Main(string[] args)
CustomRouter();
+ CustomApplicationBuilder();
+
StartupClass(args);
}
@@ -59,6 +63,24 @@ private static void CustomRouter()
}
}
+ private static void CustomApplicationBuilder()
+ {
+ // Using a application builder
+ using (WebHost.StartWith(app =>
+ {
+ app.UseStaticFiles();
+ app.Run(async context =>
+ {
+ await context.Response.WriteAsync("Hello, World!");
+ });
+ }))
+ {
+ //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022
+ Console.WriteLine("Running CustomApplicationBuilder: Press any key to shutdown and start the next sample...");
+ Console.ReadKey();
+ }
+ }
+
private static void StartupClass(string[] args)
{
// Using defaults with a Startup class
diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj
index a3520ca..6f2a348 100644
--- a/samples/SampleApp/SampleApp.csproj
+++ b/samples/SampleApp/SampleApp.csproj
@@ -12,6 +12,7 @@
+
diff --git a/samples/SampleApp/wwwroot/htmlpage.html b/samples/SampleApp/wwwroot/htmlpage.html
new file mode 100644
index 0000000..ab3af6d
--- /dev/null
+++ b/samples/SampleApp/wwwroot/htmlpage.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+ A static HTML file.
+
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs
index c1c9a86..5bd9d11 100644
--- a/src/Microsoft.AspNetCore/WebHost.cs
+++ b/src/Microsoft.AspNetCore/WebHost.cs
@@ -35,8 +35,11 @@ public static IWebHost Start(RequestDelegate app) =>
/// The URL the hosted application will listen on.
/// A delegate that handles requests to the application.
/// A started that hosts the application.
- public static IWebHost Start(string url, RequestDelegate app) =>
- StartWith(url, appBuilder => appBuilder.Run(app));
+ public static IWebHost Start(string url, RequestDelegate app)
+ {
+ var startupAssemblyName = app.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name;
+ return StartWith(url: url, configureServices: null, app: appBuilder => appBuilder.Run(app), applicationName: startupAssemblyName);
+ }
///
/// Initializes and starts a new with pre-configured defaults.
@@ -54,8 +57,11 @@ public static IWebHost Start(Action routeBuilder) =>
/// The URL the hosted application will listen on.
/// A delegate that configures the router for handling requests to the application.
/// A started that hosts the application.
- public static IWebHost Start(string url, Action routeBuilder) =>
- StartWith(url, services => services.AddRouting(), app => app.UseRouter(routeBuilder));
+ public static IWebHost Start(string url, Action routeBuilder)
+ {
+ var startupAssemblyName = routeBuilder.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name;
+ return StartWith(url, services => services.AddRouting(), appBuilder => appBuilder.UseRouter(routeBuilder), applicationName: startupAssemblyName);
+ }
///
/// Initializes and starts a new with pre-configured defaults.
@@ -74,9 +80,9 @@ public static IWebHost StartWith(Action app) =>
/// The delegate that configures the .
/// A started that hosts the application.
public static IWebHost StartWith(string url, Action app) =>
- StartWith(url: url, configureServices: null, app: app);
+ StartWith(url: url, configureServices: null, app: app, applicationName: null);
- private static IWebHost StartWith(string url, Action configureServices, Action app)
+ private static IWebHost StartWith(string url, Action configureServices, Action app, string applicationName)
{
var builder = CreateDefaultBuilder();
@@ -90,9 +96,14 @@ private static IWebHost StartWith(string url, Action configu
builder.ConfigureServices(configureServices);
}
- var host = builder
- .Configure(app)
- .Build();
+ builder.Configure(app);
+
+ if (!string.IsNullOrEmpty(applicationName))
+ {
+ builder.UseSetting(WebHostDefaults.ApplicationKey, applicationName);
+ }
+
+ var host = builder.Build();
host.Start();
@@ -109,7 +120,7 @@ private static IWebHost StartWith(string url, Action configu
/// load from 'appsettings.json' and 'appsettings.[].json',
/// load from User Secrets when is 'Development' using the entry assembly,
/// load from environment variables,
- /// configures the to log to the console,
+ /// configures the to log to the console and debug output,
/// enables IIS integration,
/// and adds the developer exception page when is 'Development'
///
@@ -128,7 +139,7 @@ public static IWebHostBuilder CreateDefaultBuilder() =>
/// load from User Secrets when is 'Development' using the entry assembly,
/// load from environment variables,
/// load from supplied command line args,
- /// configures the to log to the console,
+ /// configures the to log to the console and debug output,
/// enables IIS integration,
/// and adds the developer exception page when is 'Development'
///
@@ -165,6 +176,7 @@ public static IWebHostBuilder CreateDefaultBuilder(string[] args)
.ConfigureLogging(logging =>
{
logging.AddConsole();
+ logging.AddDebug();
})
.UseIISIntegration()
.ConfigureServices(services =>