Переадресация http на https не работает в ASP.NET CORE2.0 - PullRequest
0 голосов
/ 27 августа 2018

Я добавил приведенный ниже код для безопасной реализации https в .NetCore2.0. Защищенная связь Https работает, но перенаправление с http на https не работает.

При общении через http статус ответа "err_empty_response"

Пример:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        services.Configure<MvcOptions>(options =>
        {
            options.Filters.Add(new RequireHttpsAttribute());
        });
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
        }

        var options = new RewriteOptions()
            .AddRedirectToHttps(302, 44358);

        app.UseRewriter(options);

        app.UseStaticFiles();

        app.UseMvc();
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...