如何在Azure网站中禁用HTTPS重定向 [英] How to disable HTTPS redirection in Azure Website

查看:107
本文介绍了如何在Azure网站中禁用HTTPS重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的网站,我正在出于测试目的使用它来支持HTTP.目前,所有HTTP请求都将自动重定向到HTTPS.以下是重现该应用程序的步骤:

I have a very simple website I'm using for testing purposes that I want to support HTTP. Presently all HTTP requests are being automatically redirected to HTTPS. Here are the steps to reproduce the app:

在Visual Studio 2019中创建一个新的ASP.NET Core Web应用程序.选择ASP.NET Core 3.1,然后为项目模板选择空".禁用为HTTPS配置".右键单击新项目,然后选择发布...".将应用发布到新的应用服务.

In Visual Studio 2019 create a new ASP.NET Core Web Application. Choose ASP.NET Core 3.1 and Empty for the project template. Disable "Configure for HTTPS". Right-click the new project and select "Publish...". Publish the app to a new App Service.

发布后,浏览至网站.它将把您重定向到HTTPS.这是我已经尝试纠正的方法.

After publishing browse to the website. It will redirect you to HTTPS. Here's what I've already tried to remedy this.

在Azure门户中配置新创建的应用程序服务.确保关闭了应用程序服务身份验证.在TLS/SSL设置中,将仅HTTPS"设置为关闭.

In the Azure portal configure the newly created app service. Ensure App service authentication is off. In TLS/SSL settings set "HTTPS Only" to off.

在Program.cs中添加UseUrls选项.

In Program.cs add the UseUrls option.

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseUrls("http://localhost:8001");
            webBuilder.UseStartup<Startup>();
        });

在launchSettings.json中,确保应用程序URL使用http.

In launchSettings.json ensure the application URL uses http.

以上解决方案都没有对我有用.

None of the above solutions have worked for me.

推荐答案

我自己快速尝试了一下,可以重现您的体验. 我认为这是当仅启用HTTPS一段时间并且您在启用了设置的情况下测试了网站时,从azure网站返回的永久性301.

Just tried it real quick myself and can kinda reproduce your experience. I think it is the permanent 301 returned from the azure website when HTTPS only was ON for a while and you tested your site with the setting enabled.

您的浏览器将缓存该响应,因为它是永久重定向.

Your browser will cache that response, because its a permanent redirect.

在Chrome DEV工具中禁用缓存,然后再次使用http显式调用url,然后对我来说就很好了.

Disabling the cache in Chrome DEV tools and explicitly calling the url with http again then works just fine for me.

示例空白的空ASP.NET Core 3.1站点. (我没有在程序,启动或设置中进行任何更改.)

Example blank empty ASP.NET Core 3.1 site. (I didn't change anything in program or startup or settings.)

http://webapplication1020200429115511.azurewebsites.net/

这篇关于如何在Azure网站中禁用HTTPS重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆