Click here to Skip to main content
11,416,194 members (50,989 online)
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 2: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 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,324
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.4 | Last Updated 15 Sep 2012
Copyright © CodeProject, 1999-2015
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