James
James

Reputation: 4354

MVC Controller Parameter is null

This seems so basic but for whatever reason I can't get it to work.

Jquery..

$.post("/Member/Profile", "TESTDATA", function (result) {
    console.log(result);
});

Controller

[HttpPost]
public JsonResult Profile(string model)
{
    return Json(1);
}

My string model parameter is coming in as null, I can see that when I breakpoint on it. I've tried making it pass json, tried making it pass viewmodels, tried using ajax with Type/Method as "POST".. My parameter always seems to be coming in as null. What am I doing wrong?!

Upvotes: 2

Views: 535

Answers (2)

Muhammad Atif
Muhammad Atif

Reputation: 1102

try this
$.post("/Member/Profile", {model:'TESTDATA'}, function (result) {
    console.log(result);
});

Upvotes: 2

sTodorov
sTodorov

Reputation: 5461

Try this one?

$.post("/Member/Profile", {model: 'TESTDATA'}, function (result) {
    console.log(result);
});

Upvotes: 3

Related Questions