User-259252065 posted
I'm implementing asp.net core 3.1. I want to send a "year" value as the input parameter of my method controller. when I debug my project I can see that "year" has a value in ajax call but the argument of year in the controller method is null. I appreciate
if anyone can suggest me to solve the issue. Here is the related code in razor view:
$('#exampleModal').modal('@ViewBag.ModalState');
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var year = $("input[name='Year']:checked").val();
console.log('myyear:' + year);
//My problem is here, when sending year value to the
//ProductDetails method
$.get('@Url.Action("ProductDetails", "Home")/' + {year: year}, function (data) {
$.each(data, function (index, value) {
var markup = "<tr><td>" + value.apName +"</td></tr>";
$("#classTable").append(markup);
})
});
});
Home controller method:
public IList<ApiApplicantDTO> ProductDetails(string year)
{
Console.WriteLine("year:" + year);
}