There is a web api project on .net core 2, according to the standard VS template:
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { //пытался так избавится от этой проблемы: services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());//по идеи все разрешено }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors("AllowSpecificOrigin"); app.UseHttpsRedirection(); app.UseMvc(); } } [EnableCors("AllowSpecificOrigin")] [Route("api/")] [ApiController] public class ValuesController : ControllerBase { [HttpPost] [EnableCors("AllowSpecificOrigin")] [Route("getToursList")] public string Post([FromBody] GettingTourInfo value) { return JsonConvert.SerializeObject(value); } } If I send a request to the local server, through postman, then everything is fine. But if I send from another PC (or even from my own) through ngrok, then the ngork request appears, and the client comes in -
ERR_EMPTY_RESPONSE
and the stopping point on the method does not work. The request looks like this:
var onSubmitClick = function () { $.ajax({ url: URL_POST, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, type: 'POST', data: jsonData, AccessControlAllowOrigin : '*', AccessControlAllowHeaders : 'Content-Type', crossDomain: true, async: true, success: function(arr) { renderTours(arr); }}) I tried, except ngrok, localtunel - the same thing.