I am working in project that I need to use ajax call to save object data from my page witch contain order details. When I use project with .NET framework version 4.5, it is working very well - but when I use ASP.NET Core MVC, it is not working. Any help please?
I did try every thing in similar questions but they did not work. For example I use notation [frombody] - but I still have the same problem.
I have the following controller action:
public ActionResult CreateOrders([FromBody] T_POS_ENT_ORDER_DETIALS_Temp []T_POS_ENT_ORDER_Data)
{
GRepository<T_POS_ENT_ORDER_DETIALS_Temp> t_pos_ent_orderOpr = new GRepository<T T_POS_ENT_ORDER_DETIALS_Temp>();
T_POS_ENT_ORDER_Data.order_Date = DateTime.Now;
t_pos_ent_orderOpr.Add(T_POS_ENT_ORDER_Data);
return Json(new { msg = "Successfully added " });
}
And I have the following ajax call:
var DATA = [];
DATA.push({ LocPrice: "12" });
DATA.push({ LocProductID: "1002" });
DATA.push({ discount: "0" });
DATA.push({ posNumber: "1" });
DATA.push({ productName: "soap" });
DATA.push({ productQynt: "1" });
$.ajax({
url: '/AjaxT_POS_ENT_ORDER/CreateOrders',
data: JSON.stringify({ 'billArray': DATA }),
contentType: "application/json; charset=utf-8",
dataType: "json",
type: "POST",
async: false,
success: OnSuccess,
});
I also have this class:
public class T_POS_ENT_ORDER_DETIALS_Temp
{
public string LocPrice { get; set; }
public string LocProductID { get; set; }
public string discount { get; set; }
public string posNumber { get; set; }
public string productName { get; set; }
public int productQynt { get; set; }
}
There is no error showing only the order details is always null ...
