C# 允许从Arduino向.NET API发出HTTP POST请求

C# 允许从Arduino向.NET API发出HTTP POST请求,c#,.net,.net-core,esp8266,C#,.net,.net Core,Esp8266,我在Azure上安装并运行了一个应用程序,我正在尝试将数据从ESP8266发布到https://myApplication.azurewebservices.net/api/call。但我哪儿也去不了。ESP8266似乎在处理HTTPS时遇到问题,因此我认为应该尝试启用HTTP POST请求 我的startup类如下所示: public void ConfigureServices(IServiceCollection services) { servic

我在Azure上安装并运行了一个应用程序,我正在尝试将数据从ESP8266发布到
https://myApplication.azurewebservices.net/api/call
。但我哪儿也去不了。ESP8266似乎在处理HTTPS时遇到问题,因此我认为应该尝试启用HTTP POST请求

我的startup类如下所示:

public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddDbContext<AppDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MyDatabase")));
            services.AddIdentity<User, IdentityRole>()
                .AddEntityFrameworkStores<AppDbContext>();
            services.AddCors();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors(options => options.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
            app.UseDeveloperExceptionPage();
            app.UseAuthentication();
            app.UseMvcWithDefaultRoute();
        }
public void配置服务(IServiceCollection服务)
{
services.AddMvc();
services.AddDbContext(options=>options.UseSqlServer(Configuration.GetConnectionString(“MyDatabase”));
服务.额外性()
.AddEntityFrameworkStores();
services.AddCors();
}
//此方法由运行时调用。使用此方法配置HTTP请求管道。
公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment环境)
{
app.UseCors(options=>options.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
app.UseDeveloperExceptionPage();
app.UseAuthentication();
app.UseMvcWithDefaultRoute();
}
我认为通过允许anyheader、anyorigin和anymethod,我可以发布HTTP请求

但在《邮递员》中尝试它仍然会返回一个404,如果我这样做
http://myApplication.azurewebservices.net/api/call
,但如果我使用
https://
,它确实有效


如何使我的应用程序接受完全相同的请求,但使用HTTP而不是HTTPS?

您需要在Azure门户中专门为您的应用程序服务启用HTTP请求

Dashboard > App Service > Custom Domains > disable "HTTPS only"