Answer the question
In order to leave comments, you need to log in
Why is the method not responding to a request through ngrok?
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);
}
}
ERR_EMPTY_RESPONSE, and the breakpoint on the method doesn't fire.
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);
}
})
};
Answer the question
In order to leave comments, you need to log in
Replace https://localhost:5001;http://localhost:5000 with https://0.0.0.0:5001;http://0.0.0.0:5000
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question