runtime: Quic Support Check Throws Exception Breaking ASP.NET core
Description
I am attempting to run the ASP.NET Core Test server in a wasm context. When doing so I get the following error.
service-worker.js:86 Error: System.PlatformNotSupportedException: System.Net.Quic is not supported on this platform.
at System.Net.Quic.QuicImplementationProviders.get_Default()
at Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions.UseQuic(IWebHostBuilder hostBuilder)
at Microsoft.AspNetCore.Hosting.WebHostBuilderKestrelExtensions.UseKestrel(IWebHostBuilder hostBuilder)
at Microsoft.AspNetCore.Hosting.WebHostBuilderKestrelExtensions.UseKestrel(IWebHostBuilder hostBuilder, Action`2 configureOptions)
at Microsoft.AspNetCore.WebHost.ConfigureWebDefaults(IWebHostBuilder builder)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.<>c__DisplayClass0_0.<ConfigureWebHostDefaults>b__0(IWebHostBuilder webHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure, Action`1 configureWebHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(IHostBuilder builder, Action`1 configure)
Here is the source that triggers this error.
public static class WebHostBuilderQuicExtensions
{
[RequiresPreviewFeatures]
public static IWebHostBuilder UseQuic(this IWebHostBuilder hostBuilder)
{
if (QuicImplementationProviders.Default.IsSupported)
{
return hostBuilder.ConfigureServices(services =>
{
services.AddSingleton<IMultiplexedConnectionListenerFactory, QuicTransportFactory>();
});
}
return hostBuilder;
}
....
}
This seems like a logic error as the whole point of having the IsSupported method as the exception prevents the supported check. This prevents starting the web host in any non windows context.
Reproduction Steps
Working on a repro.
Expected behavior
The QuicImplementationProviders.Default should not throw an exception on unsupported platforms.
Or
The calling AspNet core startup logic should handle the exception.
Actual behavior
The supported check is never actually allowed to be called resulting in an unhandled exception deep in the configuration call stack which cannot be handled in way that allows the server to actually start. This would probably manifest when running not just on wasm but running ASP.NET core on older windows or linux platforms that do not support http3.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (13 by maintainers)
ASP.NET Core in wasm isn’t a supported scenario. Correct me if I’m wrong @davidfowl @SteveSandersonMS
However, this error is fixed in .NET 7, and Steve has demoed running ASP.NET Core in the browser. I think we should tell people who want to try this to use .NET 7 RCs in the short term and .NET 7 RTM or later in the long term.
If I stubbed out my own dummy implementation System.Net.Quic that had these provider methods implemented to not throw and just overwrote the existing assembly in the packaged output would that work around the issue? My understanding is the strong naming of the framework assemblies no longer matters to the runtime since the advent of .NET Core.
This is fixed in net7 in #67036