Move in-process server implementation to IIS.Server (#837)
This commit is contained in:
parent
0e7effa376
commit
34c797a46b
|
|
@ -1,4 +1,4 @@
|
|||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<Import Project="..\..\build\testsite.props" />
|
||||
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Server.IIS\Microsoft.AspNetCore.Server.IIS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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<Startup>()
|
||||
.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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,
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<byte> memoryPool, IntPtr pInProcessHandler, IISOptions options, IISHttpServer server)
|
||||
internal unsafe IISHttpContext(MemoryPool<byte> memoryPool, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server)
|
||||
: base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.HttpGetRawRequest(pInProcessHandler))
|
||||
{
|
||||
_memoryPool = memoryPool;
|
||||
|
|
@ -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<TContext> : IISHttpContext
|
||||
{
|
||||
private readonly IHttpApplication<TContext> _application;
|
||||
|
||||
public IISHttpContextOfT(MemoryPool<byte> memoryPool, IHttpApplication<TContext> application, IntPtr pInProcessHandler, IISOptions options, IISHttpServer server)
|
||||
public IISHttpContextOfT(MemoryPool<byte> memoryPool, IHttpApplication<TContext> application, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server)
|
||||
: base(memoryPool, pInProcessHandler, options, server)
|
||||
{
|
||||
_application = application;
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<IISOptions> options)
|
||||
public IISHttpServer(IApplicationLifetime applicationLifetime, IAuthenticationSchemeProvider authentication, IOptions<IISServerOptions> 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<T> _application;
|
||||
private readonly MemoryPool<byte> _memoryPool;
|
||||
private readonly IISOptions _options;
|
||||
private readonly IISServerOptions _options;
|
||||
private readonly IISHttpServer _server;
|
||||
|
||||
public IISContextFactory(MemoryPool<byte> memoryPool, IHttpApplication<T> application, IISOptions options, IISHttpServer server)
|
||||
public IISContextFactory(MemoryPool<byte> memoryPool, IHttpApplication<T> application, IISServerOptions options, IISHttpServer server)
|
||||
{
|
||||
_application = application;
|
||||
_memoryPool = memoryPool;
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||
namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
||||
{
|
||||
internal partial class AsyncIOEngine
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<int>, IValueTaskSource
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||
namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
||||
{
|
||||
internal partial class WebSocketsAsyncIOEngine
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IIS
|
|||
/// <summary>
|
||||
/// Extensions to <see cref="HttpContext"/> that enable access to IIS features.
|
||||
/// </summary>
|
||||
public static class IISHttpContextExtensions
|
||||
public static class HttpContextExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the value of a server variable for the current request.
|
||||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool AutomaticAuthentication { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the display name shown to users on login pages. The default is null.
|
||||
/// </summary>
|
||||
public string AuthenticationDisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal bool ForwardWindowsAuthentication { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,36 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageId>Microsoft.AspNetCore.Server.IIS</PackageId>
|
||||
<Description>Provides support for hosting ASP.NET Core in IIS using the AspNetCoreModule.</Description>
|
||||
<IsPackable Condition="'$(OS)' != 'Windows_NT'">false</IsPackable>
|
||||
<IncludeSource>false</IncludeSource>
|
||||
<IncludeSymbols>false</IncludeSymbols>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<NuspecFile>$(PackageId).nuspec</NuspecFile>
|
||||
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore;iis</PackageTags>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<SignedPackageFile Include="$(TargetPath)" PackagePath="lib/netstandard2.0/Microsoft.AspNetCore.Server.IIS.dll" Certificate="Microsoft" />
|
||||
<SignedPackageFile Include="aspnetcorerh_x86" PackagePath="runtimes/win-x86/nativeassets/$(TargetFramework)/aspnetcorerh.dll" Certificate="Microsoft" />
|
||||
<SignedPackageFile Include="aspnetcorerh_x64" PackagePath="runtimes/win-x64/nativeassets/$(TargetFramework)/aspnetcorerh.dll" Certificate="Microsoft" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpSys.Sources" PrivateAssets="All" Version="$(MicrosoftAspNetCoreHttpSysSourcesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Buffers.Sources" Version="$(MicrosoftExtensionsBuffersSourcesPackageVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.Buffers.MemoryPool.Sources" Version="$(MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion)" PrivateAssets="All" />
|
||||
|
||||
<PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesPackageVersion)" />
|
||||
<PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsPackageVersion)" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="$(MicrosoftAspNetCoreAuthenticationCorePackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="$(MicrosoftAspNetCoreHostingAbstractionsPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="SetPackageProperties" BeforeTargets="GenerateNuspec">
|
||||
<PropertyGroup>
|
||||
<NuspecProperties>
|
||||
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'));
|
||||
</NuspecProperties>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
|
||||
|
||||
<!-- This project doesn't actually compile anything. It's a shim into packing a nuspec -->
|
||||
<Target Name="Compile" />
|
||||
<Target Name="CopyFilesToOutputDirectory" />
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\AspNetCoreModuleV2\RequestHandler\bin\$(Configuration)\Win32\aspnetcorerh.dll" PackagePath="runtimes/win-x86/nativeassets/$(TargetFramework)/aspnetcorerh.dll" />
|
||||
<Content Include="..\AspNetCoreModuleV2\RequestHandler\bin\$(Configuration)\x64\aspnetcorerh.dll" PackagePath="runtimes/win-x64/nativeassets/$(TargetFramework)/aspnetcorerh.dll" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="hostBuilder"></param>
|
||||
/// <returns></returns>
|
||||
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<IServer, IISHttpServer>();
|
||||
services.AddSingleton<IStartupFilter>(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath));
|
||||
services.AddAuthenticationCore();
|
||||
services.Configure<IISServerOptions>(
|
||||
options => { options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return hostBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core components for working with the IIS AspNetCoreModule.</Description>
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="$(MicrosoftAspNetCoreHttpExtensionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="$(MicrosoftAspNetCoreHttpOverridesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpSys.Sources" PrivateAssets="All" Version="$(MicrosoftAspNetCoreHttpSysSourcesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Buffers.Sources" Version="$(MicrosoftExtensionsBuffersSourcesPackageVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.Buffers.MemoryPool.Sources" Version="$(MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="$(MicrosoftExtensionsOptionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.SecurityHelper.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsSecurityHelperSourcesPackageVersion)" />
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<IServer, IISHttpServer>();
|
||||
services.AddSingleton<IStartupFilter>(new IISServerSetupFilter(iisConfigData.pwzVirtualApplicationPath));
|
||||
services.AddAuthenticationCore();
|
||||
services.Configure<IISOptions>(
|
||||
options => { options.ForwardWindowsAuthentication = iisConfigData.fWindowsAuthEnabled || iisConfigData.fBasicAuthEnabled; }
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
<Import Project="..\..\..\build\testsite.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Server.IIS\Microsoft.AspNetCore.Server.IIS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace IISTestSite
|
|||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Information);
|
||||
})
|
||||
.UseIISIntegration()
|
||||
.UseIIS()
|
||||
.UseStartup(typeof(Program).Assembly.FullName)
|
||||
.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
<Import Project="..\..\..\build\testsite.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Server.IIS\Microsoft.AspNetCore.Server.IIS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace IISTestSite
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseIISIntegration()
|
||||
.UseIIS()
|
||||
.ConfigureServices(services => services.AddSingleton<IServer, DummyServer>())
|
||||
.Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); }))
|
||||
.Build();
|
||||
|
|
|
|||
Loading…
Reference in New Issue