JavaScript code:
var para = {};
para.id = $("#ad-text-id").val();
para.title = $("#ad-text-title").val().trim();
para.link = $("#ad-text-link").val().trim();
$.ajax({
url: '/ajax/AdText/SaveAdText',
data: JSON.stringify(para),
type: 'post',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function (data) {
},
error: function (xhr) {
}
});
Action code:
[HttpPost]
public async Task<JsonResult> SaveAdText(int id, string title, string link)
{
//id, title, link para is null...
}
The above code uses asp.net mvc 5 works, but use asp.net 5 does not work.
I modified the action of the code, it works.
public class Model
{
public int Id { get; set; }
public string Title { get; set; }
public string Link { get; set; }
}
[HttpPost]
public async Task<JsonResult> SaveAdText([FromBody]Model model)
{
//model.Id, model.Title, model.Link is not null...
}
Use asp.net 5, I have to write it?
JavaScript code:
Action code:
The above code uses asp.net mvc 5 works, but use asp.net 5 does not work.
I modified the action of the code, it works.
Use asp.net 5, I have to write it?