Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF中具有空值的DataMember DateTime抛出错误$http_C#_Angularjs_Wcf_Datetime - Fatal编程技术网

C# WCF中具有空值的DataMember DateTime抛出错误$http

C# WCF中具有空值的DataMember DateTime抛出错误$http,c#,angularjs,wcf,datetime,C#,Angularjs,Wcf,Datetime,我有一个带有DataMember DateTime的DataContract对象 [DataMember] public DateTime ModDateApproval { get; set; } 此字段具有转换为C#中DateTime MinValue的空值 我的WCF服务在SoapUI中工作,但在$http中不工作。我直接使用angular中的服务,当我将字段作为DataMember删除时,服务正在工作 我的问题与这个问题有关。也许DateTime只需要在web服务中进行如下操作

我有一个带有DataMember DateTime的DataContract对象

  [DataMember]
  public DateTime ModDateApproval { get; set; }
此字段具有转换为C#中DateTime MinValue的空值

我的WCF服务在SoapUI中工作,但在$http中不工作。我直接使用angular中的服务,当我将字段作为DataMember删除时,服务正在工作


我的问题与这个问题有关。也许DateTime只需要在web服务中进行如下操作:

 if(x.MyDate == DateTime.MinValue)
            {
                x.MyDate = DateTime.MinValue.ToUniversalTime();
            }

很可能是序列化问题。您要发送的日期值是什么?空日期值将自动转换为c#中的DateTime.MinValue,即1/1/0001 12:00:00 AM,现在通过在DateTime.MinValue.ToUniversalTime()中进行设置来解决;。我很好奇为什么它需要转换为.ToUniversalTime();为什么不让属性为空<代码>公共日期时间?ModDateApproval。这应该更准确地反映你的意图。将MinValue设置为世界时似乎是一个笨拙的解决方案。我想这是一个更直接的方法。谢谢