i have a class
[DataContract]
public class testing
{
[DataMember(EmitDefaultValue = false)]
public string test1{ get; set; }
[DataMember(EmitDefaultValue = false)]
public string testA{ get; set; }
[DataMember(EmitDefaultValue = false)]
public string testB{ get; set; }
}
and i have an interface
[OperationContract]
[FaultContract(typeof(CustomException))]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "SaveAliasOfEndPoints")]
bool Mymethod(testing objtesting);
and i have implementation like this
public bool Mymethod(testing objtesting)
{
return true;
}
{
"test1 ":"XXX",
"testA":"XXX",
"testB":"XXX"
}
now the problem is here
when i post json with parameter "test1 " it have space at the end
now json is parsed to my class testing in code with test1 have value null
which is wrong. i want to catch this space and throw user defined error.
please help me in this
thanks in advance