I have controller method which looks like this:
[HttpPost]
public IActionResult CreateNew(string Naslov, int KorisnikID, int GrupaID, string Tekst)
{
//Some code
}
Ajax function that is calling this is:
$.ajax({
type: "POST",
url: "/Story/CreateNew",
contentType: "application.json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
"Naslov": $("#Naslov").val(),
"KorisnikID": @Context.Request.Cookies["kid"],
"GrupaID": $("#GrupaID").val(),
"Tekst": $("#Tekst .ql-editor").html()
}),
success: function (message) {
var elements = message.split("-");
if (elements[0] == "success") {
window.location.href = '/Clanak?ID' + elements[1];
}
else {
alert(message);
}
},
error: function (xhr, status, error) {
alert(xhr + " " + status + " " + error);
}
});
Method is entered but all parameters are null.
Also when i change it to GET it works (but i need post since i have problem with length of string)