I have Get method like below
[HttpGet]
public IActionResult GetAllData()
{
var sorgu = "SELECT CODE,NAME,CITY FROM CUSTOMER";
using (var db=new BulutContext())
{
var adap=new SqlDataAdapter(sorgu, db.Database.GetConnectionString());
var dt = new DataTable();
adap.Fill(dt);
List<Customers> model = new List<Customers>();
model = (from DataRow dr in dt.Rows
select new Customers
{
CODE = dr[0].ToString(),
NAME = dr[1].ToString(),
CITY = dr[2].ToString()
}).ToList();
return Ok(model);
}
also this line added in startup.cs
services.AddCors(c =>
{
c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin());
});
app.UseCors(options => options.AllowAnyOrigin());
when testing in postman its return error 405 Method Not Allowed.