User1308320631 posted
Hi.
I have a .net core api which works before locally. However, when deploying I get a "no Access-Control-Allow-Origin" header present issue.
I have Cors added in Startus.cs:
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
If I call directly, I get a json result perfectly but Ajax gives me this error. On another pc, it gives ERR_CONNECTION_RESET.
The Controller method is:
[HttpPost]
public List<ProductViewModel> GetGenerics(string searchText)
{
List<ProductViewModel> lst = new List<ProductViewModel>();
ProModel prod = new ProViewModel() { Name = "test", IsOrder = true };
lst.Add(prod);
return lst;
}
Can anyone help here?
Thanks