jciibrahim wrote:dears
i need to call endpoint from custom controller not core controller
public class PayTabsController : BaseController
{
[ValidateAntiForgeryToken]
[HttpPost]
[Route("OnGetAddress")]
public IActionResult OnGetAddress(string addressId, string customerId){}
}
and the view is
$.ajax({
type: "POST",
url: '/PayTabs/OnGetAddress?addressId=' + addressId + '&customerId=' [email protected]().GetAwaiter().GetResult().Id,
and it said not found :(
add routeprovide or what to do? to make it work.
please help
and thanks inadvance
You are using [ValidateAntiForgeryToken] in your action method so you have to pass addAntiForgeryToken(data); in your ajax request.
read: {
url: "@Html.Raw(Url.Action("ListLogs", "ActivityLog"))",
type: "POST",
dataType: "json",
data: function() {
var data = {
CreatedOnFrom: $('#@Html.IdFor(model => model.CreatedOnFrom)').val(),
CreatedOnTo: $('#@Html.IdFor(model => model.CreatedOnTo)').val(),
IpAddress: $('#@Html.IdFor(model => model.IpAddress)').val(),
ActivityLogTypeId: $('#ActivityLogTypeId').val()
};
addAntiForgeryToken(data);
return data;
}
},