in my controller:
public class ShoppingCartController : Controller
{
public ActionResult Index()
{
return View(this.HttpContext);
}
...
}
in view:i try to send the httpcontext to api method as following.
var urll = 'https://localhost:44379/api/apiClass/IndexOfCarts';
$.ajax({
type: "post",
url: urll, error: function () { alert("error carts") },
@*data: JSON.stringify(@Model.HttpContext, null, '\t'),*@
data: { httpContext: @Model},
success: function (dataa) {
alert("****ok carts****")
}
});
in api action:
[Microsoft.AspNetCore.Mvc.HttpPost()]
public ActionResult<string> IndexOfCarts([FromForm]HttpContext httpContext)
{
return "ddd";
}
the api action dont call.but when change the parameter to another types and use ajax to request to api action, the api action called and work
What I have tried:
i change[fromform] to [frombody] for parameter,but also the api not called.(The program does not go to the api action)