Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF JSON REST
Hii,
 
In the REST services I have created my [DataContract] looks like this :
[DataContract]
public class Emp
{
[DataMember]
public Guid Eid {get;set;}
[DataMember]
public string Ename{get;set;}
[DataMember]
public DateTime CreatedDate{get;set;}
 
}
 
I am retrieving the results from database(SQL) and I am retrieving "Ename" value based on Eid.I wrote SQL query and its working fine.I am returing a list .Now I want to display it as JSON response .However I can view the XML response clearly like this :
<Eid>00000000-0000-0000-0000-000000000000</Eid>
<Ename>John</Ename>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
When I decorate my OperationContract like this 
 [OperationContract]
        [WebInvoke(UriTemplate = "GetEName/?id={eid}", Method= "GET",ResponseFormat=WebMessageFormat.Json)]
        Emp GetName(Guid eid); 
and run the application then I am getting error:"[Fiddler] ReadResponse() failed: The server did not return a response for this request."
 
I guess this is only because browser is not taking default date to be 0001-01-01T00:00:00 in JSON response
 
How can I make this corrected and get the response when the returned date is 0001-01-01T00:00:00?What are the modifications I have to do in the code(DataContract) ?
 
Thanks in advance...
Posted 15-Sep-12 1:24am
cutie1297

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hiii,
refer this link
 
if date is null then just replace it with blank space
 
WCF REST Service with JSON[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 676
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,198
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,470


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 15 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100