2014-12-03 71 views
0

這可能是一個愚蠢的問題,但我正在執行POST,並且我的整數字段以十六進制值返回到我的控制器。Ajax json POSTing返回十六進制而不是整數

var VM = { 
    cn_number: ko.observable(), 
    engineer_id: ko.observable(), 
    date_start: ko.observable(), 
    paper_first_lot: ko.observable(), 
    new_chemicals: ko.observable(), 
    new_laborcodes: ko.observable(), 
    new_equipment: ko.observable(), 
    save: function() { 
     var self = this; 
     var token = $('[name=__RequestVerificationToken]').val(); 
     var headers = {}; 
     headers["__RequestVerificationToken"] = token; 
     $.ajax({ 
      type: "POST", 
      url: '/nris/Create', 
      headers: headers, 
      dataType: 'json', 
      data: ko.toJSON(self), 
      contentType: 'application/json', 
      success: function (result) { }, 
      error: function (err) { 
       if (err.responseText == "Creation Failed"){} 
       // window.location.href = '/nris/Index/'; 
       else 
        alert("Status: " + err.responseText); 
      } 
     }); 
    }, 
}; 

我的控制器:

[HttpPost] 
    public string Create(DTO incomingModel) 
    { 
     if (ModelState.IsValid){    
      _nriRepository.InsertOrUpdateNRI(incomingModel); 
      return "Created"; 
     } 
     return "Creation Failed"; 
    } 

當我看到incomingModel,整數值返回爲0x0 ##### ......我一直在尋找所有的論壇,但似乎無法找到像這樣的東西。我堅持坐在這裏轉換每個字段爲int?

+0

好......胡說。我知道這是愚蠢的..謝謝! – chickenricekid 2014-12-03 21:40:05

回答