'Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware: Error: 'MS-ASPNETCORE-TOKEN' does not match the expected pairing token, request rejected

I am receiving this error, Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware: Error: 'MS-ASPNETCORE-TOKEN' does not match the expected pairing token, request rejected, when running in Visual Studio, whether debugging or not. I know there are similar questions but they have not provided a solution/answer yet. Here is the code that generates the error:

public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseKestrel(options =>
                {
                    options.ConfigureEndpointDefaults(listenOptions =>
                    {
                        listenOptions.UseConnectionLogging();
                    });
                })
                .UseStartup<Startup>()
                .UseKeyVaultConfigProvider()
                .Build();
    }

In the appsettings file, I set the url to "applicationUrl": "https://localhost:5001;http://localhost:5000". I have also tried adding .UseIISIntegration(). Any other suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source