I Try to send FormData()
to ASP.NET MVC Controller but same data is null.ExternalProjects, CertificateUniverSitys,...
$('#Controller').on('click', '#SaveProfile', function() {
debugger;
var CertificateInstitutions = JSON.parse(localStorage.getItem("CertificateInstitutionsListLocal"));
var CertificateUniverSitys = JSON.parse(localStorage.getItem("CertificateUniverSitysListLocal"));
var ExternalProjects = JSON.parse(localStorage.getItem("ExProjectListLocal"));
var soical = {
GithubId: $('#GithubId').val(),
StackowerflowId: $('#StackowerflowId').val(),
TweiterId: $('#TweiterId').val()
}
var SkillList = $('select.tagit-hiddenSelect :selected').map(function() {
return this.value;
}).get();
var form = $('#CreateProfileForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();
var file_data = $("#Image").prop("files")[0];
var fd = new FormData();
fd.append("isFirst", true);
fd.append("token", token);
fd.append("image", file_data);
fd.append("soical", soical);
fd.append("SkillList", SkillList);
fd.append("ExternalProjects", ExternalProjects);
fd.append("CertificateUniverSitys", CertificateUniverSitys);
fd.append("CertificateInstitutions", CertificateInstitutions);
$.ajax({
url: '@postUrl',
method: "POST",
contentType: false,
processData: false,
data: fd
});
});
public virtual async Task<ActionResult> CreatePrfile(CreateFreelancerProfileViewModel viewModel, bool isFirst, HttpPostedFileBase image)
public class CreateFreelancerProfileViewModel : BaseViewModel
{
#region Collocations
public ExternalProjectViewModel[] ExternalProjects { get; set; }
public CertificateUniverSityViewModel[] CertificateUniverSitys { get; set; }
public CertificateInstitutionsViewModel[] CertificateInstitutions { get; set; }
public SoicalViewModel Soical { get; set; }
#endregion
}