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 a37f27a96e..3180ce1915 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Microsoft.AspNetCore.Server.IISIntegration.csproj @@ -2,7 +2,7 @@ ASP.NET Core components for working with the IIS AspNetCoreModule. - netstandard2.0 + netstandard2.0;netcoreapp2.1 $(NoWarn);CS1591 true aspnetcore;iis diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs index 4f8c2ce10e..eef84d69b8 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/NativeMethods.cs @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration [DllImport(AspNetCoreModuleDll)] private static extern int http_get_server_variable( IntPtr pInProcessHandler, - [MarshalAs(UnmanagedType.AnsiBStr)] string variableName, + [MarshalAs(UnmanagedType.LPStr)] string variableName, [MarshalAs(UnmanagedType.BStr)] out string value); [DllImport(AspNetCoreModuleDll)] diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs index 5b1a5262c2..ce32f8d401 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs @@ -144,16 +144,25 @@ namespace Microsoft.AspNetCore.Server.IISIntegration var server = (IISHttpServer)GCHandle.FromIntPtr(pvRequestContext).Target; Interlocked.Increment(ref server._outstandingRequests); - _ = Task.Run( - async () => { - var context = server._iisContextFactory.CreateHttpContext(pInProcessHandler); - var result = await context.ProcessRequestAsync();; - CompleteRequest(context, result); - }); - +#if NETCOREAPP2_1 + ThreadPool.QueueUserWorkItem<(IISHttpServer, IntPtr)>( + state => _ = HandleRequest(state.Item1, state.Item2), + (server, pInProcessHandler), + preferLocal: false); +#else + ThreadPool.QueueUserWorkItem( + state => _ = HandleRequest(server, pInProcessHandler)); +#endif return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING; } + private static async Task HandleRequest(IISHttpServer server, IntPtr handler) + { + var context = server._iisContextFactory.CreateHttpContext(handler); + var result = await context.ProcessRequestAsync(); + CompleteRequest(context, result); + } + private static bool HandleShutdown(IntPtr pvRequestContext) { var server = (IISHttpServer)GCHandle.FromIntPtr(pvRequestContext).Target;