The parameters dictionary contains a null entry for parameter 'appId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ContentResult CheckForInstaller(Int32)' in 'HLIT_TicketingMVC.Controllers.TicketController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
function SubmitAjax(url, message, successFunc, errorFunc) {
$.ajax({
type:'POST',
url:url,
data:message,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success:successFunc,
error:errorFunc
});
};
The data object is built as follows:
var message={"appId":application.val()};
I have also tried a jsonified string:
var message="{'appId':"+application.val()+"}";
and
var message="{'appId':'"+application.val()+"'}";
I validated that the message is coming through with a proper int value before it tries to post. The mouse over debugger most recently showed: {appId="6"}
The method signature on the controller is:
public ContentResult CheckForInstaller(int appId)
When I remove the parameter from the method signature, it does hit the breakpoint inside, so it's either the signature needing attributes of some kind, or the message isn't built properly I believe.
Remove this:
contentType: 'application/json; charset=utf-8',
MVC isn't going to parse the JSON into an int
. You want the default value of application/x-www-form-urlencoded
.
I think it maybe that you are sending json to the controller try this
function SubmitAjax(url, message, successFunc, errorFunc) {
$.ajax({
type:'POST',
url:url,
data:"appId=" + application.val(),//not sure where you get the value from in your current code
dataType: 'json',
success:successFunc,
error:errorFunc
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With