ASP.NET Webforms app error: MetadataAddress or Authority must use HTTPS unless disabled for developm

moondaddy 911 Reputation points
2022-02-10T01:24:27.867+00:00

Using VS 2022 I just created a new Asp.Net app using the Weforms tamplate along with Asp.net Identity authentication. I built the app and tried to run it but get this error in the browser:

The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.

I had no option other than using https in the template setup. You would think VS would configure this to run without error and of course I don't have a ssl certificate ready at hand to use. I googled the error but only found examples related to this in c# and I don't know where in c# to set this. I assumed it would be web.config setting but found zero examples of this in google.

any advise on how to get past this error so I can run the app?

Thanks.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,288 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 25,876 Reputation points Microsoft Vendor
    2022-02-10T06:22:22.773+00:00

    Hi @moondaddy ,
    I think you need to add JwtBearerOptions.RequireHttpsMetadata as false, but only disable in development environment.
    https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectoptions.requirehttpsmetadata?view=aspnetcore-5.0

     public void ConfigureServices(IServiceCollection services)  
            {  
                services.AddAuthentication(options =>  
                {  
                    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;  
                    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;  
          
                }).AddJwtBearer(options =>  
                {  
                    options.Authority = Configuration["Auth0:Authority"];  
                    options.Audience = Configuration["Auth0:Audience"];  
                    options.RequireHttpsMetadata = false;  
                });            
            }  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.