Add routing to web host (#4358)

This commit is contained in:
James Newton-King 2018-12-04 08:22:23 +13:00 committed by GitHub
parent d852e10293
commit b2b16253af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -222,6 +222,8 @@ namespace Microsoft.AspNetCore
new ConfigurationChangeTokenSource<HostFilteringOptions>(hostingContext.Configuration));
services.AddTransient<IStartupFilter, HostFilteringStartupFilter>();
services.AddRouting();
})
.UseIIS()
.UseIISIntegration();

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Threading;
using Microsoft.AspNetCore.HostFiltering;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -54,6 +55,17 @@ namespace Microsoft.AspNetCore.Tests
Assert.Contains("NewHost", options.AllowedHosts);
}
[Fact]
public void CreateDefaultBuilder_RegistersRouting()
{
var host = WebHost.CreateDefaultBuilder()
.Configure(_ => { })
.Build();
var linkGenerator = host.Services.GetService(typeof(LinkGenerator));
Assert.NotNull(linkGenerator);
}
[Fact]
public void CreateDefaultBuilder_RegistersEventSourceLogger()
{