Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用“在本地主机上运行我的.Net web应用”;https";而不是",;http「;在Mac Os上_C#_Asp.net_Asp.net Core_Ssl_Https - Fatal编程技术网

C# 如何使用“在本地主机上运行我的.Net web应用”;https";而不是",;http「;在Mac Os上

C# 如何使用“在本地主机上运行我的.Net web应用”;https";而不是",;http「;在Mac Os上,c#,asp.net,asp.net-core,ssl,https,C#,Asp.net,Asp.net Core,Ssl,Https,我现在的问题是,在上运行我的应用程序时,我总是遇到以下错误https://localhost:5000: This site can’t provide a secure connection. localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR 我所做的是: 添加app.UseHsts(但这仅用于生产环境,不用于开发) 添加app.UseHttpsRedirection() 运行dotnet dev certs https-

我现在的问题是,在上运行我的应用程序时,我总是遇到以下错误https://localhost:5000:

This site can’t provide a secure connection. 
localhost sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
我所做的是:

  • 添加
    app.UseHsts
    (但这仅用于生产环境,不用于开发)
  • 添加
    app.UseHttpsRedirection()
  • 运行
    dotnet dev certs https--trust
    (如果我再次运行它,我会得到
    一个有效的https证书已经存在
  • 重新启动浏览器/系统
  • 清除缓存
  • 我仍然得到了错误。从我阅读的文档来看,这应该足够了

    还有什么我该做的吗

    这是我完整的
    Startup.cs
    code

    public void ConfigureServices(IServiceCollection services)
            {
                services.ConfigureNonBreakingSameSiteCookies();
    
                // services.AddHttpsRedirection(options => {
                //     options.HttpsPort = 5000;
                // });
    
                services.AddMicrosoftIdentityWebAppAuthentication(Configuration, "AzureAdB2C")
                         .EnableTokenAcquisitionToCallDownstreamApi(new string[] { Configuration["VivobodyApi:Scope"] })
                         .AddInMemoryTokenCaches();
    
                services.AddControllersWithViews()
                        .AddMicrosoftIdentityUI();
    
                services.AddRazorPages();
                services.AddServerSideBlazor().AddMicrosoftIdentityConsentHandler();
                //services.AddSingleton<ResultsService>();
    
                services.AddHttpClient<IVivobodyApiService, VivobodyApiService>(configureClient =>
                {
                    configureClient.BaseAddress = new Uri(Configuration.GetSection("VivobodyApi:Url").Value);
                })
                .AddPolicyHandler(GetRetryPolicy(services))
                .AddPolicyHandler(GetCircuitBreakerPolicy(services));
    
                services.AddHttpContextAccessor();
                services.AddTransient<IIdentityService, IdentityService>();
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
                else
                {
                    app.UseExceptionHandler("/Error");
                    app.UseHsts();
                }
    
                app.UseHttpsRedirection();
                app.UseStaticFiles();
    
                app.UseRouting();
    
                app.UseCookiePolicy();
    
                app.UseAuthentication();
                app.UseAuthorization();
    
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                    endpoints.MapBlazorHub();
                    endpoints.MapFallbackToPage("/_Host");
                });
            }
    
    public void配置服务(IServiceCollection服务)
    {
    services.ConfigureNonBreakingSameSiteCookies();
    //services.AddHttpsRedirection(选项=>{
    //options.HttpsPort=5000;
    // });
    services.AddMicrosoftIdentityWebAppAuthentication(配置,“AzureAdB2C”)
    .EnableTokenAcquisitionTollDownstreamAPI(新字符串[]{Configuration[“VivobodyApi:Scope”]})
    .AddInMemoryTokenCaches();
    services.AddControllersWithViews()
    .AddMicrosoftIdentityUI();
    services.AddRazorPages();
    services.AddServerSideBlazor().AddMicrosoftIdentityConsentHandler();
    //services.AddSingleton();
    services.AddHttpClient(configureClient=>
    {
    configureClient.BaseAddress=新Uri(Configuration.GetSection(“VivobodyApi:Url”).Value);
    })
    .AddPolicyHandler(GetRetryPolicy(服务))
    .AddPolicyHandler(GetCircuitBreakerPolicy(服务));
    AddHttpContextAccessor();
    services.AddTransient();
    }
    //此方法由运行时调用。使用此方法配置HTTP请求管道。
    public void配置(IApplicationBuilder应用程序、IWebHostEnvironment环境)
    {
    if(env.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    }
    其他的
    {
    app.UseExceptionHandler(“/Error”);
    app.UseHsts();
    }
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseCookiePolicy();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseEndpoints(端点=>
    {
    endpoints.MapControllers();
    endpoints.MapBlazorHub();
    endpoints.MapFallbackToPage(“/_主机”);
    });
    }