В приложении dot.net core MVC, я передаю параметры с помощью AJAX. В контроллер приходит NULL
Код JS
function LoginPasswordSave() {
var isValid = true;
if ($('#Login').val() == "") {
$('#Login').css('border-color', 'Red');
isValid = false;
}
else {
$('#Login').css('border-color', 'lightgrey');
}
if ($('#Password').val() == "") {
$('#Password').css('border-color', 'Red');
isValid = false;
}
else {
$('#Password').css('border-color', 'lightgrey');
}
if (isValid == false) {
return false;
}
var data = {
//'ID': ID,
'Login': $('#Login').val(),
'Password': $('#Password').val(),
};
console.log(data);
$.ajax({
url: "/Home/LoginPasswordSave/",
type: "POST",
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
dataType: "html",
success: function (result) {
$('#ServicesModalContent').html(result);
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
}
КОД Controller
using System;
using HealthCore.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Web;
using System.IO;
[HttpPost]
public ActionResult LoginPasswordSave(string Login, string Password)
{
try
{
//User us = new User();
//us.Name = Login;
//us.Password = Password;
//db.User.Add(us);
//db.SaveChanges();
ViewBag.Message = "Пользователь успешно добавлен!";
}
catch (Exception ex)
{
ViewBag.Message = ex.ToString();
}
return PartialView();
}