我的ASP.NET MVC操作是这样编写的:
//
// GET: /TaxStatements/CalculateTax/{prettyId}
public ActionResult CalculateTax(int prettyId)
{
if (prettyId == 0)
return Json(true, JsonRequestBehavior.AllowGet);
TaxStatement selected = _repository.Load(prettyId);
return Json(selected.calculateTax, JsonRequestBehavior.AllowGet); // calculateTax is of type bool
}
我曾经遇到这个问题,因为在使用它的jquery函数中,我遇到了各种错误,主要是toLowerCase()
函数失败。
所以,我不得不改变操作方式,以便它们返回bool作为字符串(在bool值上调用ToString()
),这样它们就会返回true
或false
(在引号内),但我有点不喜欢这种方式。
其他人如何处理这种情况?