我有一个KnockoutJS视图模型,我将其作为JSON对象发布到MVC控制器,如下所示:
var dataObj = ko.toJSON(viewModel);
$.post(postURL, dataObj, callBackFunc);
模型本身有出生日期:
dataObj.DOB
但是每当我的MVC控制器收到它时,DOB字段总是#12:00:00 AM#
(VB.NET)
以下是我的控制器:
<HttpPost()> _
<AjaxOnly()> _
Public Function PersonalDetails(PersonalInfo As DetailsViewModel.PersonalDetails)
'clean the null values
Dim newValues As Dictionary(Of String, String) = _getPropertyDict(PersonalInfo)
Dim repo As New DetailsViewModelRepository()
For Each entry In newValues
repo.InsertUpdateField(PersonalInfo.MemberId, entry.Key, entry.Value)
Next
Return PartialView("~/Views/Home/Details/PersonalDetails.vbhtml", PersonalInfo)
End Function
如何让它正确收到日期?
答案 0 :(得分:0)
我尝试了以下内容并且它有效,只是不确定浏览器兼容性的范围:
dataObj.DOB = dataObj.DOB.toISOString();