I am developing the REST enabled WCF Service. I am using the following code inside the interface.
[OperationContract]
//[WebGet]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
List<String> GetProjects();
I want the method should return the JSON response. I am passing the parameter through the URL as follows.
http://localhost:51565/RestWebService/Search.svc/GetProjects
Now when I use the above URL in the address bar, the browser ask me for downloading the file. I am new the REST web service & also JSON. I am not aware whether in the above case I am getting the JSON response or something else ? How can I identify that the above response is the JSON response ?
Most of the the current browsers do not render Json when they see the media-type application/json. You will run into this problem with many media types. My suggestion is to just stop trying to debug using a web browser.
Install fiddler. It will save you.
Fiddler is a debugging tool for working with HTTP. You will be able to see exactly what is being transmitted to and from your service and you will be able to create POST requests in order to test your service.
It does take a bit of time to get used to but it is well worth it if you are doing any amount of work with HTTP.