diff --git a/build/dependencies.props b/build/dependencies.props index 3c87fd414e..f454a5cd9b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) diff --git a/samples/NativeIISSample/NativeIISSample.csproj b/samples/NativeIISSample/NativeIISSample.csproj index 9c88fbe560..7785cbb5ac 100644 --- a/samples/NativeIISSample/NativeIISSample.csproj +++ b/samples/NativeIISSample/NativeIISSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ - + diff --git a/samples/NativeIISSample/Startup.cs b/samples/NativeIISSample/Startup.cs index 1a41f5a848..0744ef4cf1 100644 --- a/samples/NativeIISSample/Startup.cs +++ b/samples/NativeIISSample/Startup.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.IIS; -using Microsoft.AspNetCore.Server.IISIntegration; namespace NativeIISSample { @@ -42,7 +41,7 @@ namespace NativeIISSample await context.Response.WriteAsync(Environment.NewLine); await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine); - var scheme = await authSchemeProvider.GetSchemeAsync(IISDefaults.AuthenticationScheme); + var scheme = await authSchemeProvider.GetSchemeAsync(IISServerDefaults.AuthenticationScheme); await context.Response.WriteAsync("DisplayName: " + scheme?.DisplayName + Environment.NewLine); await context.Response.WriteAsync(Environment.NewLine); @@ -99,7 +98,7 @@ namespace NativeIISSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseIISIntegration() + .UseIIS() .UseStartup() .Build(); diff --git a/src/Microsoft.AspNetCore.Server.IIS/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Server.IIS/AssemblyInfo.cs new file mode 100644 index 0000000000..f08839f842 --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.IIS/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// 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.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Server.IISIntegration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] + diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/DuplexStream.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/DuplexStream.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/DuplexStream.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/DuplexStream.cs index f8ebd8d792..46cda59046 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/DuplexStream.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/DuplexStream.cs @@ -6,7 +6,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { // TODO redudant file, remove // See https://github.com/aspnet/IISIntegration/issues/426 diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISConfigurationData.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISConfigurationData.cs similarity index 92% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISConfigurationData.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISConfigurationData.cs index 76910ca9d3..8f1f473766 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISConfigurationData.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISConfigurationData.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { [StructLayout(LayoutKind.Sequential)] internal unsafe struct IISConfigurationData diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.FeatureCollection.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.FeatureCollection.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.FeatureCollection.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.FeatureCollection.cs index 1acdc3e36d..60f651acdf 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.FeatureCollection.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.FeatureCollection.cs @@ -6,16 +6,16 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Net; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Server.IIS.Core.IO; using Microsoft.AspNetCore.WebUtilities; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal partial class IISHttpContext : IFeatureCollection, IHttpRequestFeature, diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.Features.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.Features.cs similarity index 99% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.Features.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.Features.cs index 6733ba74c5..0064899340 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.Features.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.Features.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal partial class IISHttpContext { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpConnectionFeature.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpConnectionFeature.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpConnectionFeature.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpConnectionFeature.cs index d5a72cf013..40b70a2b90 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpConnectionFeature.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpConnectionFeature.cs @@ -5,7 +5,7 @@ using System.Globalization; using System.Net; using Microsoft.AspNetCore.Http.Features; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal partial class IISHttpContext : IHttpConnectionFeature { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpRequestIdentifierFeature.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpRequestIdentifierFeature.cs similarity index 96% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpRequestIdentifierFeature.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpRequestIdentifierFeature.cs index 68112f607c..2d735a7d8f 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.IHttpRequestIdentifierFeature.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.IHttpRequestIdentifierFeature.cs @@ -4,7 +4,7 @@ using System; using Microsoft.AspNetCore.Http.Features; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal partial class IISHttpContext : IHttpRequestIdentifierFeature { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.ReadWrite.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.ReadWrite.cs similarity index 99% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.ReadWrite.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.ReadWrite.cs index 839eefc1e9..740c2a2d3e 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.ReadWrite.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.ReadWrite.cs @@ -6,7 +6,7 @@ using System.Buffers; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal partial class IISHttpContext { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.cs index 92ccdf3326..2668fb1485 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContext.cs @@ -5,7 +5,6 @@ using System; using System.Buffers; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.IO; using System.IO.Pipelines; using System.Net; @@ -18,10 +17,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpSys.Internal; +using Microsoft.AspNetCore.Server.IIS.Core.IO; using Microsoft.AspNetCore.WebUtilities; -using Microsoft.Extensions.Logging; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal abstract partial class IISHttpContext : NativeRequestContext, IDisposable { @@ -32,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration protected readonly IntPtr _pInProcessHandler; - private readonly IISOptions _options; + private readonly IISServerOptions _options; private volatile bool _hasResponseStarted; private volatile bool _hasRequestReadingStarted; @@ -64,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private const string BasicString = "Basic"; - internal unsafe IISHttpContext(MemoryPool memoryPool, IntPtr pInProcessHandler, IISOptions options, IISHttpServer server) + internal unsafe IISHttpContext(MemoryPool memoryPool, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server) : base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.HttpGetRawRequest(pInProcessHandler)) { _memoryPool = memoryPool; diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContextOfT.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContextOfT.cs index e3152802bc..f24c4fe93e 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpContextOfT.cs @@ -8,13 +8,13 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting.Server; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class IISHttpContextOfT : IISHttpContext { private readonly IHttpApplication _application; - public IISHttpContextOfT(MemoryPool memoryPool, IHttpApplication application, IntPtr pInProcessHandler, IISOptions options, IISHttpServer server) + public IISHttpContextOfT(MemoryPool memoryPool, IHttpApplication application, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server) : base(memoryPool, pInProcessHandler, options, server) { _application = application; diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpRequestBody.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpRequestBody.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpRequestBody.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpRequestBody.cs index 87d7742dfa..d4f6241f98 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpRequestBody.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpRequestBody.cs @@ -6,7 +6,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class IISHttpRequestBody : Stream { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpResponseBody.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpResponseBody.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpResponseBody.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpResponseBody.cs index f850994a4a..76e913bb4b 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpResponseBody.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpResponseBody.cs @@ -6,7 +6,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class IISHttpResponseBody : Stream { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpServer.cs similarity index 95% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpServer.cs index 49518926ce..df6b9a20b6 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISHttpServer.cs @@ -13,7 +13,7 @@ using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Options; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class IISHttpServer : IServer { @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private GCHandle _httpServerHandle; private readonly IApplicationLifetime _applicationLifetime; private readonly IAuthenticationSchemeProvider _authentication; - private readonly IISOptions _options; + private readonly IISServerOptions _options; private volatile int _stopping; private bool Stopping => _stopping == 1; @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration return _websocketAvailable.Value; } - public IISHttpServer(IApplicationLifetime applicationLifetime, IAuthenticationSchemeProvider authentication, IOptions options) + public IISHttpServer(IApplicationLifetime applicationLifetime, IAuthenticationSchemeProvider authentication, IOptions options) { _applicationLifetime = applicationLifetime; _authentication = authentication; @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration if (_options.ForwardWindowsAuthentication) { - authentication.AddScheme(new AuthenticationScheme(IISDefaults.AuthenticationScheme, _options.AuthenticationDisplayName, typeof(IISServerAuthenticationHandler))); + authentication.AddScheme(new AuthenticationScheme(IISServerDefaults.AuthenticationScheme, _options.AuthenticationDisplayName, typeof(IISServerAuthenticationHandler))); } } @@ -197,10 +197,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration { private readonly IHttpApplication _application; private readonly MemoryPool _memoryPool; - private readonly IISOptions _options; + private readonly IISServerOptions _options; private readonly IISHttpServer _server; - public IISContextFactory(MemoryPool memoryPool, IHttpApplication application, IISOptions options, IISHttpServer server) + public IISContextFactory(MemoryPool memoryPool, IHttpApplication application, IISServerOptions options, IISHttpServer server) { _application = application; _memoryPool = memoryPool; diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISServerAuthenticationHandler.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerAuthenticationHandler.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISServerAuthenticationHandler.cs index 587490bf50..7031df34ea 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISServerAuthenticationHandler.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { public class IISServerAuthenticationHandler : IAuthenticationHandler { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IISServerSetupFilter.cs similarity index 95% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IISServerSetupFilter.cs index 787c979c96..f3c3613565 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISServerSetupFilter.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IISServerSetupFilter.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.Extensions.DependencyInjection; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class IISServerSetupFilter : IStartupFilter { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Flush.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Flush.cs similarity index 95% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Flush.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Flush.cs index f0b30dcf2f..1187c5b3f2 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Flush.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Flush.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class AsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Read.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Read.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Read.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Read.cs index 207ce9efc4..00c6709453 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Read.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Read.cs @@ -4,7 +4,7 @@ using System; using System.Buffers; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class AsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Write.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Write.cs similarity index 95% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Write.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Write.cs index 8bd708797d..72be9f107b 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.Write.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.Write.cs @@ -4,7 +4,7 @@ using System; using Microsoft.AspNetCore.HttpSys.Internal; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class AsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.cs similarity index 99% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.cs index dbb8bd2331..614367255a 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOEngine.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOEngine.cs @@ -8,7 +8,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class AsyncIOEngine : IAsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOOperation.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOOperation.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOOperation.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOOperation.cs index a2368b3987..a7bea2e746 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncIOOperation.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncIOOperation.cs @@ -7,7 +7,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks.Sources; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal abstract class AsyncIOOperation: IValueTaskSource, IValueTaskSource { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncWriteOperationBase.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncWriteOperationBase.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncWriteOperationBase.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncWriteOperationBase.cs index 480c34da66..3be67095fd 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/AsyncWriteOperationBase.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/AsyncWriteOperationBase.cs @@ -5,7 +5,7 @@ using System; using System.Buffers; using Microsoft.AspNetCore.HttpSys.Internal; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal abstract class AsyncWriteOperationBase : AsyncIOOperation { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/IAsyncIOEngine.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/IAsyncIOEngine.cs similarity index 90% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/IAsyncIOEngine.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/IAsyncIOEngine.cs index 99ae8d66bb..6e6896b8c4 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/IAsyncIOEngine.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/IAsyncIOEngine.cs @@ -5,7 +5,7 @@ using System; using System.Buffers; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal interface IAsyncIOEngine: IDisposable { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Initialize.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Initialize.cs similarity index 95% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Initialize.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Initialize.cs index 1d139e3395..10e1f0da7d 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Initialize.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Initialize.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class WebSocketsAsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Read.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Read.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Read.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Read.cs index 66054f8564..413fa77703 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Read.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Read.cs @@ -5,7 +5,7 @@ using System; using System.Buffers; using System.Runtime.InteropServices; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class WebSocketsAsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Write.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Write.cs similarity index 97% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Write.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Write.cs index 66631d7b63..3eff3bba46 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.Write.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.Write.cs @@ -5,7 +5,7 @@ using System; using System.Runtime.InteropServices; using Microsoft.AspNetCore.HttpSys.Internal; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class WebSocketsAsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.cs index 795a9311fe..0c04523cb0 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IO/WebSocketsAsyncIOEngine.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/IO/WebSocketsAsyncIOEngine.cs @@ -6,7 +6,7 @@ using System.Buffers; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core.IO { internal partial class WebSocketsAsyncIOEngine: IAsyncIOEngine { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs b/src/Microsoft.AspNetCore.Server.IIS/Core/OutputProducer.cs similarity index 98% rename from src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs rename to src/Microsoft.AspNetCore.Server.IIS/Core/OutputProducer.cs index af774afcb9..4bf1816329 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/Core/OutputProducer.cs @@ -7,7 +7,7 @@ using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.AspNetCore.Server.IISIntegration +namespace Microsoft.AspNetCore.Server.IIS.Core { internal class OutputProducer { diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/IISHttpContextExtensions.cs b/src/Microsoft.AspNetCore.Server.IIS/HttpContextExtensions.cs similarity index 96% rename from src/Microsoft.AspNetCore.Server.IISIntegration/IISHttpContextExtensions.cs rename to src/Microsoft.AspNetCore.Server.IIS/HttpContextExtensions.cs index fd72e9d00f..9c0092d3fe 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/IISHttpContextExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.IIS/HttpContextExtensions.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IIS /// /// Extensions to that enable access to IIS features. /// - public static class IISHttpContextExtensions + public static class HttpContextExtensions { /// /// Gets the value of a server variable for the current request. diff --git a/src/Microsoft.AspNetCore.Server.IIS/IISDefaults.cs b/src/Microsoft.AspNetCore.Server.IIS/IISDefaults.cs new file mode 100644 index 0000000000..5be4a086f8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.IIS/IISDefaults.cs @@ -0,0 +1,12 @@ +// 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. + +namespace Microsoft.AspNetCore.Server.IIS +{ + public class IISServerDefaults + { + public static readonly string AuthenticationScheme = "Windows"; + public const string Negotiate = "Negotiate"; + public const string Ntlm = "NTLM"; + } +} diff --git a/src/Microsoft.AspNetCore.Server.IIS/IISServerOptions.cs b/src/Microsoft.AspNetCore.Server.IIS/IISServerOptions.cs new file mode 100644 index 0000000000..feed9180a5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.IIS/IISServerOptions.cs @@ -0,0 +1,26 @@ +// 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. + +namespace Microsoft.AspNetCore.Builder +{ + public class IISServerOptions + { + /// + /// If true the server should set HttpContext.User. If false the server will only provide an + /// identity when explicitly requested by the AuthenticationScheme. + /// Note Windows Authentication must also be enabled in IIS for this to work. + /// + public bool AutomaticAuthentication { get; set; } = true; + + /// + /// Sets the display name shown to users on login pages. The default is null. + /// + public string AuthenticationDisplayName { get; set; } + + /// + /// Used to indicate if the authentication handler should be registered. This is only done if ANCM indicates + /// IIS has a non-anonymous authentication enabled, or for back compat with ANCMs that did not provide this information. + /// + internal bool ForwardWindowsAuthentication { get; set; } = true; + } +} diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/IServerVariablesFeature.cs b/src/Microsoft.AspNetCore.Server.IIS/IServerVariableFeature.cs similarity index 100% rename from src/Microsoft.AspNetCore.Server.IISIntegration/IServerVariablesFeature.cs rename to src/Microsoft.AspNetCore.Server.IIS/IServerVariableFeature.cs diff --git a/src/Microsoft.AspNetCore.Server.IIS/Microsoft.AspNetCore.Server.IIS.csproj b/src/Microsoft.AspNetCore.Server.IIS/Microsoft.AspNetCore.Server.IIS.csproj index 51cc16d958..ed8b42bc55 100644 --- a/src/Microsoft.AspNetCore.Server.IIS/Microsoft.AspNetCore.Server.IIS.csproj +++ b/src/Microsoft.AspNetCore.Server.IIS/Microsoft.AspNetCore.Server.IIS.csproj @@ -1,56 +1,36 @@ - - - + - netcoreapp2.1 + netstandard2.0 Microsoft.AspNetCore.Server.IIS Provides support for hosting ASP.NET Core in IIS using the AspNetCoreModule. false - false - false - false - false - true - $(PackageId).nuspec - true + $(NoWarn);CS1591 + true + aspnetcore;iis + true + - + + + + + + + + + - - - - id=$(PackageId); - tfm=$(TargetFramework); - tfmGroup=$(TargetFrameworkIdentifier)$(_TargetFrameworkVersionWithoutV); - configuration=$(Configuration); - copyright=$(Copyright); - author=$(Authors); - licenseUrl=$(PackageLicenseUrl); - iconUrl=$(PackageIconUrl); - projectUrl=$(PackageProjectUrl); - repositoryUrl=$(RepositoryUrl); - repositoryType=$(RepositoryType); - repositoryCommit=$(RepositoryCommit); - version=$(PackageVersion); - description=$(Description); - serviceable=$([MSBuild]::ValueOrDefault('$(Serviceable)', 'false')); - - - - - - - - - - + + + + diff --git a/src/Microsoft.AspNetCore.Server.IIS/NativeMethods.cs b/src/Microsoft.AspNetCore.Server.IIS/NativeMethods.cs new file mode 100644 index 0000000000..a736edb2ca --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.IIS/NativeMethods.cs @@ -0,0 +1,274 @@ +// 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; +using System.Runtime.InteropServices; +using Microsoft.AspNetCore.HttpSys.Internal; +using Microsoft.AspNetCore.Server.IIS.Core; + +namespace Microsoft.AspNetCore.Server.IIS +{ + internal static class NativeMethods + { + internal const int HR_OK = 0; + internal const int ERROR_NOT_FOUND = unchecked((int)0x80070490); + internal const int ERROR_OPERATION_ABORTED = unchecked((int)0x800703E3); + + private const string KERNEL32 = "kernel32.dll"; + + private const string AspNetCoreModuleDll = "aspnetcorerh.dll"; + + [DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)] + + public static extern bool CloseHandle(IntPtr handle); + + + [DllImport("kernel32.dll")] + private static extern IntPtr GetModuleHandle(string lpModuleName); + + public static bool IsAspNetCoreModuleLoaded() + { + return GetModuleHandle(AspNetCoreModuleDll) != IntPtr.Zero; + } + + public enum REQUEST_NOTIFICATION_STATUS + { + RQ_NOTIFICATION_CONTINUE, + RQ_NOTIFICATION_PENDING, + RQ_NOTIFICATION_FINISH_REQUEST + } + + public delegate REQUEST_NOTIFICATION_STATUS PFN_REQUEST_HANDLER(IntPtr pInProcessHandler, IntPtr pvRequestContext); + public delegate bool PFN_SHUTDOWN_HANDLER(IntPtr pvRequestContext); + public delegate REQUEST_NOTIFICATION_STATUS PFN_ASYNC_COMPLETION(IntPtr pvManagedHttpContext, int hr, int bytes); + public delegate REQUEST_NOTIFICATION_STATUS PFN_WEBSOCKET_ASYNC_COMPLETION(IntPtr pInProcessHandler, IntPtr completionInfo, IntPtr pvCompletionContext); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_post_completion(IntPtr pInProcessHandler, int cbBytes); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_set_completion_status(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS rquestNotificationStatus); + + [DllImport(AspNetCoreModuleDll)] + private static extern void http_indicate_completion(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS notificationStatus); + + [DllImport(AspNetCoreModuleDll)] + private static extern void register_callbacks(PFN_REQUEST_HANDLER request_callback, PFN_SHUTDOWN_HANDLER shutdown_callback, PFN_ASYNC_COMPLETION managed_context_handler, IntPtr pvRequestContext, IntPtr pvShutdownContext); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_write_response_bytes(IntPtr pInProcessHandler, HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, int nChunks, out bool fCompletionExpected); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_flush_response_bytes(IntPtr pInProcessHandler, out bool fCompletionExpected); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe HttpApiTypes.HTTP_REQUEST_V2* http_get_raw_request(IntPtr pInProcessHandler); + + [DllImport(AspNetCoreModuleDll)] + private static extern void http_stop_calls_into_managed(); + + [DllImport(AspNetCoreModuleDll)] + private static extern void http_stop_incoming_requests(); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe HttpApiTypes.HTTP_RESPONSE_V2* http_get_raw_response(IntPtr pInProcessHandler); + + [DllImport(AspNetCoreModuleDll, CharSet = CharSet.Ansi)] + private static extern int http_set_response_status_code(IntPtr pInProcessHandler, ushort statusCode, string pszReason); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_read_request_bytes(IntPtr pInProcessHandler, byte* pvBuffer, int cbBuffer, out int dwBytesReceived, out bool fCompletionExpected); + + [DllImport(AspNetCoreModuleDll)] + private static extern void http_get_completion_info(IntPtr pCompletionInfo, out int cbBytes, out int hr); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_set_managed_context(IntPtr pInProcessHandler, IntPtr pvManagedContext); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_get_application_properties(ref IISConfigurationData iiConfigData); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_get_server_variable( + IntPtr pInProcessHandler, + [MarshalAs(UnmanagedType.LPStr)] string variableName, + [MarshalAs(UnmanagedType.BStr)] out string value); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_websockets_read_bytes( + IntPtr pInProcessHandler, + byte* pvBuffer, + int cbBuffer, + PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, + IntPtr pvCompletionContext, + out int dwBytesReceived, + out bool fCompletionExpected); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_websockets_write_bytes( + IntPtr pInProcessHandler, + HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, + int nChunks, + PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, + IntPtr pvCompletionContext, + out bool fCompletionExpected); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_enable_websockets(IntPtr pInProcessHandler); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_cancel_io(IntPtr pInProcessHandler); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_response_set_unknown_header(IntPtr pInProcessHandler, byte* pszHeaderName, byte* pszHeaderValue, ushort usHeaderValueLength, bool fReplace); + + [DllImport(AspNetCoreModuleDll)] + private static extern unsafe int http_response_set_known_header(IntPtr pInProcessHandler, int headerId, byte* pHeaderValue, ushort length, bool fReplace); + + [DllImport(AspNetCoreModuleDll)] + private static extern int http_get_authentication_information(IntPtr pInProcessHandler, [MarshalAs(UnmanagedType.BStr)] out string authType, out IntPtr token); + + public static void HttpPostCompletion(IntPtr pInProcessHandler, int cbBytes) + { + Validate(http_post_completion(pInProcessHandler, cbBytes)); + } + + public static void HttpSetCompletionStatus(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS rquestNotificationStatus) + { + Validate(http_set_completion_status(pInProcessHandler, rquestNotificationStatus)); + } + + public static void HttpIndicateCompletion(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS notificationStatus) + { + http_indicate_completion(pInProcessHandler, notificationStatus); + } + public static void HttpRegisterCallbacks(PFN_REQUEST_HANDLER request_callback, PFN_SHUTDOWN_HANDLER shutdown_callback, PFN_ASYNC_COMPLETION managed_context_handler, IntPtr pvRequestContext, IntPtr pvShutdownContext) + { + register_callbacks(request_callback, shutdown_callback, managed_context_handler, pvRequestContext, pvShutdownContext); + } + + public static unsafe int HttpWriteResponseBytes(IntPtr pInProcessHandler, HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, int nChunks, out bool fCompletionExpected) + { + return http_write_response_bytes(pInProcessHandler, pDataChunks, nChunks, out fCompletionExpected); + } + + public static int HttpFlushResponseBytes(IntPtr pInProcessHandler, out bool fCompletionExpected) + { + return http_flush_response_bytes(pInProcessHandler, out fCompletionExpected); + } + public static unsafe HttpApiTypes.HTTP_REQUEST_V2* HttpGetRawRequest(IntPtr pInProcessHandler) + { + return http_get_raw_request(pInProcessHandler); + } + + public static void HttpStopCallsIntoManaged() + { + http_stop_calls_into_managed(); + } + + public static void HttpStopIncomingRequests() + { + http_stop_incoming_requests(); + } + + public static unsafe HttpApiTypes.HTTP_RESPONSE_V2* HttpGetRawResponse(IntPtr pInProcessHandler) + { + return http_get_raw_response(pInProcessHandler); + } + + public static void HttpSetResponseStatusCode(IntPtr pInProcessHandler, ushort statusCode, string pszReason) + { + Validate(http_set_response_status_code(pInProcessHandler, statusCode, pszReason)); + } + + public static unsafe int HttpReadRequestBytes(IntPtr pInProcessHandler, byte* pvBuffer, int cbBuffer, out int dwBytesReceived, out bool fCompletionExpected) + { + return http_read_request_bytes(pInProcessHandler, pvBuffer, cbBuffer, out dwBytesReceived, out fCompletionExpected); + } + + public static void HttpGetCompletionInfo(IntPtr pCompletionInfo, out int cbBytes, out int hr) + { + http_get_completion_info(pCompletionInfo, out cbBytes, out hr); + } + + public static void HttpSetManagedContext(IntPtr pInProcessHandler, IntPtr pvManagedContext) + { + Validate(http_set_managed_context(pInProcessHandler, pvManagedContext)); + } + + public static IISConfigurationData HttpGetApplicationProperties() + { + var iisConfigurationData = new IISConfigurationData(); + Validate(http_get_application_properties(ref iisConfigurationData)); + return iisConfigurationData; + } + + public static bool HttpTryGetServerVariable(IntPtr pInProcessHandler, string variableName, out string value) + { + return http_get_server_variable(pInProcessHandler, variableName, out value) == 0; + } + + public static unsafe int HttpWebsocketsReadBytes( + IntPtr pInProcessHandler, + byte* pvBuffer, + int cbBuffer, + PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, + IntPtr pvCompletionContext, out int dwBytesReceived, + out bool fCompletionExpected) + { + return http_websockets_read_bytes(pInProcessHandler, pvBuffer, cbBuffer, pfnCompletionCallback, pvCompletionContext, out dwBytesReceived, out fCompletionExpected); + } + + public static unsafe int HttpWebsocketsWriteBytes( + IntPtr pInProcessHandler, + HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, + int nChunks, + PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, + IntPtr pvCompletionContext, + out bool fCompletionExpected) + { + return http_websockets_write_bytes(pInProcessHandler, pDataChunks, nChunks, pfnCompletionCallback, pvCompletionContext, out fCompletionExpected); + } + + public static void HttpEnableWebsockets(IntPtr pInProcessHandler) + { + Validate(http_enable_websockets(pInProcessHandler)); + } + + public static bool HttpTryCancelIO(IntPtr pInProcessHandler) + { + var hr = http_cancel_io(pInProcessHandler); + // Async operation finished + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363792(v=vs.85).aspx + if (hr == ERROR_NOT_FOUND) + { + return false; + } + Validate(hr); + return true; + } + + public static unsafe void HttpResponseSetUnknownHeader(IntPtr pInProcessHandler, byte* pszHeaderName, byte* pszHeaderValue, ushort usHeaderValueLength, bool fReplace) + { + Validate(http_response_set_unknown_header(pInProcessHandler, pszHeaderName, pszHeaderValue, usHeaderValueLength, fReplace)); + } + + public static unsafe void HttpResponseSetKnownHeader(IntPtr pInProcessHandler, int headerId, byte* pHeaderValue, ushort length, bool fReplace) + { + Validate(http_response_set_known_header(pInProcessHandler, headerId, pHeaderValue, length, fReplace)); + } + + public static void HttpGetAuthenticationInformation(IntPtr pInProcessHandler, out string authType, out IntPtr token) + { + Validate(http_get_authentication_information(pInProcessHandler, out authType, out token)); + } + + private static void Validate(int hr) + { + if (hr != HR_OK) + { + throw Marshal.GetExceptionForHR(hr); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Server.IIS/WebHostBuilderIISExtensions.cs b/src/Microsoft.AspNetCore.Server.IIS/WebHostBuilderIISExtensions.cs new file mode 100644 index 0000000000..e5ca048afc --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.IIS/WebHostBuilderIISExtensions.cs @@ -0,0 +1,50 @@ +// 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; +using System.Runtime.InteropServices; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Server.IIS; +using Microsoft.AspNetCore.Server.IIS.Core; + +namespace Microsoft.AspNetCore.Hosting +{ + public static class WebHostBuilderIISExtensions + { + /// + /// Configures the port and base path the server should listen on when running behind AspNetCoreModule. + /// The app will also be configured to capture startup errors. + /// + /// + /// + public static IWebHostBuilder UseIIS(this IWebHostBuilder hostBuilder) + { + if (hostBuilder == null) + { + throw new ArgumentNullException(nameof(hostBuilder)); + } + + // Check if in process + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && NativeMethods.IsAspNetCoreModuleLoaded()) + { + hostBuilder.CaptureStartupErrors(true); + + var iisConfigData = NativeMethods.HttpGetApplicationProperties(); + hostBuilder.UseContentRoot(iisConfigData.pwzFullApplicationPath); + return hostBuilder.ConfigureServices( + services => { + services.AddSingleton(); + services.AddSingleton(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath)); + services.AddAuthenticationCore(); + services.Configure( + options => { options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; } + ); + }); + } + + return hostBuilder; + } + } +} diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj b/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj index a17b331554..f816c8de3f 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core components for working with the IIS AspNetCoreModule. @@ -21,9 +21,6 @@ - - - diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs index ece7f954c6..02fc967f1a 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs @@ -3,271 +3,15 @@ using System; using System.Runtime.InteropServices; -using Microsoft.AspNetCore.HttpSys.Internal; namespace Microsoft.AspNetCore.Server.IISIntegration { internal static class NativeMethods { - internal const int HR_OK = 0; - internal const int ERROR_NOT_FOUND = unchecked((int)0x80070490); - internal const int ERROR_OPERATION_ABORTED = unchecked((int)0x800703E3); - private const string KERNEL32 = "kernel32.dll"; - private const string AspNetCoreModuleDll = "aspnetcorerh.dll"; - [DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)] public static extern bool CloseHandle(IntPtr handle); - - - [DllImport("kernel32.dll")] - private static extern IntPtr GetModuleHandle(string lpModuleName); - - public static bool IsAspNetCoreModuleLoaded() - { - return GetModuleHandle(AspNetCoreModuleDll) != IntPtr.Zero; - } - - public enum REQUEST_NOTIFICATION_STATUS - { - RQ_NOTIFICATION_CONTINUE, - RQ_NOTIFICATION_PENDING, - RQ_NOTIFICATION_FINISH_REQUEST - } - - public delegate REQUEST_NOTIFICATION_STATUS PFN_REQUEST_HANDLER(IntPtr pInProcessHandler, IntPtr pvRequestContext); - public delegate bool PFN_SHUTDOWN_HANDLER(IntPtr pvRequestContext); - public delegate REQUEST_NOTIFICATION_STATUS PFN_ASYNC_COMPLETION(IntPtr pvManagedHttpContext, int hr, int bytes); - public delegate REQUEST_NOTIFICATION_STATUS PFN_WEBSOCKET_ASYNC_COMPLETION(IntPtr pInProcessHandler, IntPtr completionInfo, IntPtr pvCompletionContext); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_post_completion(IntPtr pInProcessHandler, int cbBytes); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_set_completion_status(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS rquestNotificationStatus); - - [DllImport(AspNetCoreModuleDll)] - private static extern void http_indicate_completion(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS notificationStatus); - - [DllImport(AspNetCoreModuleDll)] - private static extern void register_callbacks(PFN_REQUEST_HANDLER request_callback, PFN_SHUTDOWN_HANDLER shutdown_callback, PFN_ASYNC_COMPLETION managed_context_handler, IntPtr pvRequestContext, IntPtr pvShutdownContext); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_write_response_bytes(IntPtr pInProcessHandler, HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, int nChunks, out bool fCompletionExpected); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_flush_response_bytes(IntPtr pInProcessHandler, out bool fCompletionExpected); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe HttpApiTypes.HTTP_REQUEST_V2* http_get_raw_request(IntPtr pInProcessHandler); - - [DllImport(AspNetCoreModuleDll)] - private static extern void http_stop_calls_into_managed(); - - [DllImport(AspNetCoreModuleDll)] - private static extern void http_stop_incoming_requests(); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe HttpApiTypes.HTTP_RESPONSE_V2* http_get_raw_response(IntPtr pInProcessHandler); - - [DllImport(AspNetCoreModuleDll, CharSet = CharSet.Ansi)] - private static extern int http_set_response_status_code(IntPtr pInProcessHandler, ushort statusCode, string pszReason); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_read_request_bytes(IntPtr pInProcessHandler, byte* pvBuffer, int cbBuffer, out int dwBytesReceived, out bool fCompletionExpected); - - [DllImport(AspNetCoreModuleDll)] - private static extern void http_get_completion_info(IntPtr pCompletionInfo, out int cbBytes, out int hr); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_set_managed_context(IntPtr pInProcessHandler, IntPtr pvManagedContext); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_get_application_properties(ref IISConfigurationData iiConfigData); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_get_server_variable( - IntPtr pInProcessHandler, - [MarshalAs(UnmanagedType.LPStr)] string variableName, - [MarshalAs(UnmanagedType.BStr)] out string value); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_websockets_read_bytes( - IntPtr pInProcessHandler, - byte* pvBuffer, - int cbBuffer, - PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, - IntPtr pvCompletionContext, - out int dwBytesReceived, - out bool fCompletionExpected); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_websockets_write_bytes( - IntPtr pInProcessHandler, - HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, - int nChunks, - PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, - IntPtr pvCompletionContext, - out bool fCompletionExpected); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_enable_websockets(IntPtr pInProcessHandler); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_cancel_io(IntPtr pInProcessHandler); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_response_set_unknown_header(IntPtr pInProcessHandler, byte* pszHeaderName, byte* pszHeaderValue, ushort usHeaderValueLength, bool fReplace); - - [DllImport(AspNetCoreModuleDll)] - private static extern unsafe int http_response_set_known_header(IntPtr pInProcessHandler, int headerId, byte* pHeaderValue, ushort length, bool fReplace); - - [DllImport(AspNetCoreModuleDll)] - private static extern int http_get_authentication_information(IntPtr pInProcessHandler, [MarshalAs(UnmanagedType.BStr)] out string authType, out IntPtr token); - - public static void HttpPostCompletion(IntPtr pInProcessHandler, int cbBytes) - { - Validate(http_post_completion(pInProcessHandler, cbBytes)); - } - - public static void HttpSetCompletionStatus(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS rquestNotificationStatus) - { - Validate(http_set_completion_status(pInProcessHandler, rquestNotificationStatus)); - } - - public static void HttpIndicateCompletion(IntPtr pInProcessHandler, REQUEST_NOTIFICATION_STATUS notificationStatus) - { - http_indicate_completion(pInProcessHandler, notificationStatus); - } - public static void HttpRegisterCallbacks(PFN_REQUEST_HANDLER request_callback, PFN_SHUTDOWN_HANDLER shutdown_callback, PFN_ASYNC_COMPLETION managed_context_handler, IntPtr pvRequestContext, IntPtr pvShutdownContext) - { - register_callbacks(request_callback, shutdown_callback, managed_context_handler, pvRequestContext, pvShutdownContext); - } - - public static unsafe int HttpWriteResponseBytes(IntPtr pInProcessHandler, HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, int nChunks, out bool fCompletionExpected) - { - return http_write_response_bytes(pInProcessHandler, pDataChunks, nChunks, out fCompletionExpected); - } - - public static int HttpFlushResponseBytes(IntPtr pInProcessHandler, out bool fCompletionExpected) - { - return http_flush_response_bytes(pInProcessHandler, out fCompletionExpected); - } - public static unsafe HttpApiTypes.HTTP_REQUEST_V2* HttpGetRawRequest(IntPtr pInProcessHandler) - { - return http_get_raw_request(pInProcessHandler); - } - - public static void HttpStopCallsIntoManaged() - { - http_stop_calls_into_managed(); - } - - public static void HttpStopIncomingRequests() - { - http_stop_incoming_requests(); - } - - public static unsafe HttpApiTypes.HTTP_RESPONSE_V2* HttpGetRawResponse(IntPtr pInProcessHandler) - { - return http_get_raw_response(pInProcessHandler); - } - - public static void HttpSetResponseStatusCode(IntPtr pInProcessHandler, ushort statusCode, string pszReason) - { - Validate(http_set_response_status_code(pInProcessHandler, statusCode, pszReason)); - } - - public static unsafe int HttpReadRequestBytes(IntPtr pInProcessHandler, byte* pvBuffer, int cbBuffer, out int dwBytesReceived, out bool fCompletionExpected) - { - return http_read_request_bytes(pInProcessHandler, pvBuffer, cbBuffer, out dwBytesReceived, out fCompletionExpected); - } - - public static void HttpGetCompletionInfo(IntPtr pCompletionInfo, out int cbBytes, out int hr) - { - http_get_completion_info(pCompletionInfo, out cbBytes, out hr); - } - - public static void HttpSetManagedContext(IntPtr pInProcessHandler, IntPtr pvManagedContext) - { - Validate(http_set_managed_context(pInProcessHandler, pvManagedContext)); - } - - public static IISConfigurationData HttpGetApplicationProperties() - { - var iisConfigurationData = new IISConfigurationData(); - Validate(http_get_application_properties(ref iisConfigurationData)); - return iisConfigurationData; - } - - public static bool HttpTryGetServerVariable(IntPtr pInProcessHandler, string variableName, out string value) - { - return http_get_server_variable(pInProcessHandler, variableName, out value) == 0; - } - - public static unsafe int HttpWebsocketsReadBytes( - IntPtr pInProcessHandler, - byte* pvBuffer, - int cbBuffer, - PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, - IntPtr pvCompletionContext, out int dwBytesReceived, - out bool fCompletionExpected) - { - return http_websockets_read_bytes(pInProcessHandler, pvBuffer, cbBuffer, pfnCompletionCallback, pvCompletionContext, out dwBytesReceived, out fCompletionExpected); - } - - public static unsafe int HttpWebsocketsWriteBytes( - IntPtr pInProcessHandler, - HttpApiTypes.HTTP_DATA_CHUNK* pDataChunks, - int nChunks, - PFN_WEBSOCKET_ASYNC_COMPLETION pfnCompletionCallback, - IntPtr pvCompletionContext, - out bool fCompletionExpected) - { - return http_websockets_write_bytes(pInProcessHandler, pDataChunks, nChunks, pfnCompletionCallback, pvCompletionContext, out fCompletionExpected); - } - - public static void HttpEnableWebsockets(IntPtr pInProcessHandler) - { - Validate(http_enable_websockets(pInProcessHandler)); - } - - public static bool HttpTryCancelIO(IntPtr pInProcessHandler) - { - var hr = http_cancel_io(pInProcessHandler); - // Async operation finished - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363792(v=vs.85).aspx - if (hr == ERROR_NOT_FOUND) - { - return false; - } - Validate(hr); - return true; - } - - public static unsafe void HttpResponseSetUnknownHeader(IntPtr pInProcessHandler, byte* pszHeaderName, byte* pszHeaderValue, ushort usHeaderValueLength, bool fReplace) - { - Validate(http_response_set_unknown_header(pInProcessHandler, pszHeaderName, pszHeaderValue, usHeaderValueLength, fReplace)); - } - - public static unsafe void HttpResponseSetKnownHeader(IntPtr pInProcessHandler, int headerId, byte* pHeaderValue, ushort length, bool fReplace) - { - Validate(http_response_set_known_header(pInProcessHandler, headerId, pHeaderValue, length, fReplace)); - } - - public static void HttpGetAuthenticationInformation(IntPtr pInProcessHandler, out string authType, out IntPtr token) - { - Validate(http_get_authentication_information(pInProcessHandler, out authType, out token)); - } - - private static void Validate(int hr) - { - if (hr != HR_OK) - { - throw Marshal.GetExceptionForHR(hr); - } - } } } diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs index c236c7eac4..b57ad38b00 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/WebHostBuilderIISExtensions.cs @@ -40,13 +40,6 @@ namespace Microsoft.AspNetCore.Hosting return hostBuilder; } - // Check if in process - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && NativeMethods.IsAspNetCoreModuleLoaded()) - { - - return SetupInProcessServer(hostBuilder); - } - var port = hostBuilder.GetSetting(ServerPort) ?? Environment.GetEnvironmentVariable($"ASPNETCORE_{ServerPort}"); var path = hostBuilder.GetSetting(ServerPath) ?? Environment.GetEnvironmentVariable($"ASPNETCORE_{ServerPath}"); var pairingToken = hostBuilder.GetSetting(PairingToken) ?? Environment.GetEnvironmentVariable($"ASPNETCORE_{PairingToken}"); @@ -107,23 +100,5 @@ namespace Microsoft.AspNetCore.Hosting return hostBuilder; } - - private static IWebHostBuilder SetupInProcessServer(IWebHostBuilder hostBuilder) - { - hostBuilder.UseSetting(nameof(UseIISIntegration), "true"); - hostBuilder.CaptureStartupErrors(true); - - var iisConfigData = NativeMethods.HttpGetApplicationProperties(); - hostBuilder.UseContentRoot(iisConfigData.pwzFullApplicationPath); - return hostBuilder.ConfigureServices( - services => { - services.AddSingleton(); - services.AddSingleton(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath)); - services.AddAuthenticationCore(); - services.Configure( - options => { options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; } - ); - }); - } } } diff --git a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj index abe0a117f7..75b4860528 100644 --- a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj +++ b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj @@ -1,7 +1,7 @@ - $(StandardTestTfms) + netcoreapp2.1 diff --git a/test/IISIntegration.FunctionalTests/Utilities/IISTestSiteFixture.cs b/test/IISIntegration.FunctionalTests/Utilities/IISTestSiteFixture.cs index a097f3672d..5fef8660ca 100644 --- a/test/IISIntegration.FunctionalTests/Utilities/IISTestSiteFixture.cs +++ b/test/IISIntegration.FunctionalTests/Utilities/IISTestSiteFixture.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Threading; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Testing; namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { @@ -16,6 +17,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public IISTestSiteFixture() { + var logging = AssemblyTestLog.ForAssembly(typeof(IISTestSiteFixture).Assembly); + var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(), ServerType.IISExpress, RuntimeFlavor.CoreClr, @@ -25,10 +28,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests SiteName = "HttpTestSite", TargetFramework = "netcoreapp2.1", ApplicationType = ApplicationType.Portable, - ANCMVersion = ANCMVersion.AspNetCoreModuleV2 + ANCMVersion = ANCMVersion.AspNetCoreModuleV2, }; - _deployer = ApplicationDeployerFactory.Create(deploymentParameters, NullLoggerFactory.Instance); + _deployer = ApplicationDeployerFactory.Create(deploymentParameters, logging.CreateLoggerFactory(null, nameof(IISTestSiteFixture))); DeploymentResult = _deployer.DeployAsync().Result; Client = DeploymentResult.HttpClient; BaseUri = DeploymentResult.ApplicationBaseUri; diff --git a/test/WebSites/InProcessWebSite/InProcessWebSite.csproj b/test/WebSites/InProcessWebSite/InProcessWebSite.csproj index dd7cb4e794..987b624cc9 100644 --- a/test/WebSites/InProcessWebSite/InProcessWebSite.csproj +++ b/test/WebSites/InProcessWebSite/InProcessWebSite.csproj @@ -2,11 +2,11 @@ - $(StandardTestTfms) + netcoreapp2.1 - + diff --git a/test/WebSites/InProcessWebSite/Program.cs b/test/WebSites/InProcessWebSite/Program.cs index 0550f0f1fd..e9db174529 100644 --- a/test/WebSites/InProcessWebSite/Program.cs +++ b/test/WebSites/InProcessWebSite/Program.cs @@ -16,7 +16,7 @@ namespace IISTestSite factory.AddConsole(); factory.AddFilter("Console", level => level >= LogLevel.Information); }) - .UseIISIntegration() + .UseIIS() .UseStartup(typeof(Program).Assembly.FullName) .Build(); diff --git a/test/WebSites/InProcessWebSite/Startup.WebSockets.cs b/test/WebSites/InProcessWebSite/Startup.WebSockets.cs index 453f8db254..f3fcdb3a1d 100644 --- a/test/WebSites/InProcessWebSite/Startup.WebSockets.cs +++ b/test/WebSites/InProcessWebSite/Startup.WebSockets.cs @@ -3,24 +3,17 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Net; using System.Net.WebSockets; -using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; using IISIntegration.FunctionalTests; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Server.IIS; -using Microsoft.AspNetCore.Server.IISIntegration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Primitives; using Xunit; namespace IISTestSite diff --git a/test/WebSites/InProcessWebSite/Startup.cs b/test/WebSites/InProcessWebSite/Startup.cs index a872c7bc1b..93717f8703 100644 --- a/test/WebSites/InProcessWebSite/Startup.cs +++ b/test/WebSites/InProcessWebSite/Startup.cs @@ -2,24 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Net; -using System.Net.WebSockets; using System.Reflection; using System.Text; -using System.Threading; using System.Threading.Tasks; -using IISIntegration.FunctionalTests; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.IIS; -using Microsoft.AspNetCore.Server.IISIntegration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Primitives; using Xunit; @@ -46,7 +38,7 @@ namespace IISTestSite app.Run(async ctx => { var varName = ctx.Request.Query["q"]; - await ctx.Response.WriteAsync($"{varName}: {ctx.GetIISServerVariable(varName) ?? "(null)"}"); + await ctx.Response.WriteAsync($"{varName}: {HttpContextExtensions.GetIISServerVariable(ctx, varName) ?? "(null)"}"); }); } @@ -68,7 +60,7 @@ namespace IISTestSite } else { - await ctx.ChallengeAsync(IISDefaults.AuthenticationScheme); + await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); } }); } @@ -77,7 +69,7 @@ namespace IISTestSite { app.Run(async ctx => { - await ctx.ForbidAsync(IISDefaults.AuthenticationScheme); + await ctx.ForbidAsync(IISServerDefaults.AuthenticationScheme); }); } @@ -91,7 +83,7 @@ namespace IISTestSite } else { - await ctx.ChallengeAsync(IISDefaults.AuthenticationScheme); + await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); } }); } diff --git a/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj b/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj index 4332ea3fd1..746ac2f2d3 100644 --- a/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj +++ b/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj @@ -3,11 +3,11 @@ - $(StandardTestTfms) + netcoreapp2.1 - + - + diff --git a/test/WebSites/OverriddenServerWebSite/Program.cs b/test/WebSites/OverriddenServerWebSite/Program.cs index bb65e03004..2b68c93af4 100644 --- a/test/WebSites/OverriddenServerWebSite/Program.cs +++ b/test/WebSites/OverriddenServerWebSite/Program.cs @@ -18,7 +18,7 @@ namespace IISTestSite public static void Main(string[] args) { var host = new WebHostBuilder() - .UseIISIntegration() + .UseIIS() .ConfigureServices(services => services.AddSingleton()) .Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); })) .Build();