Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 515127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:35:46+00:00 2026-05-13T07:35:46+00:00

I am not sure what is wrong with my JSON response from WCF but

  • 0

I am not sure what is wrong with my JSON response from WCF but it is not being parsed properly. I probably made a simple mistake, hopefully someone can spot it. I am using VS 2008 Pro SP1.

When I navigate directly to the url Chrome thinks it is a file download. When I hit say flickr’s service it returned a string inline in the browser body, which makes me think my content is being sent incorrectly.

Service

[ServiceContract]
public interface IFoo
{
    [OperationContract]
    [WebGet(UriTemplate = "/foos/", ResponseFormat = WebMessageFormat.Json]
    Foo[] GetFoos();
}

Model

// this is in a separate assembly from the service
[DataContract]
public class Foo
{
    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string Name { get; set; }
}

JQuery

$(document).ready(function() {
    $.getJSON(fooUrl, function(data) {
        alert(data); // data is an object, but data.items is null
            // this complains 'length is null or not an object'
            $.each(data.items, function(i, item) { 
                fooList.append('<option value="' + data[i].id + '">' + data[i].name + '</option>');
            });
        });
    });

When I look at the response in Fiddler I see:

 [{"Id":1,"Name":"Foo1"},{"Id":2,"Name":"Foo2"},{"Id":3,"Name":"Foo3"}]

Update

Here are the raw headers from fiddler for the response comparison (me vs. flickr)

Mine

HTTP/1.1 200 OK
Content-Length: 162
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0

Flickr

HTTP/1.1 200 OK
Date: Sat, 12 Dec 2009 00:30:36 GMT
P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Sat, 12 Dec 2009 00:26:19 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: application/x-javascript; charset=utf-8

It looks like the big difference is I have application/json and they have application/x-javascript. As I noted above I am using WebMessageFormat.Json on the operation contract.

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:35:46+00:00Added an answer on May 13, 2026 at 7:35 am

    I believe that application/json is the correct media type for what you are doing.

    The fact that the browser does not render it and simply gives you a file download dialog is not unsurprising. Browsers only render directly a very small set of media types.

    It does not mean that there is anything wrong with what your web service is returning. It just means that the browser does not have any built in capability to convert json into an html representation for display purposes.

    If you retrieve this json representation in your client code you should be able to handle as you do any other json data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a news feed where items in the feed are created from JSON
I am trying to return a JSON object from an aspx page using Jayrock.JSON.
Is there a way to get the Content-Type of the response or conversely set
I just ran into something weird. I have two JSON arrays which holds different
Is there a way to pass a list as a function argument to eval()
i have jquery global error event set, like following: $(#message_alert).ajaxError(function(event, XMLHttpRequest, settings, thrownError){ ajax_error(XMLHttpRequest);
I've having an issue with consuming a particular feed for a client. They have
I have a problem passing in a complex type into a controller. Here is
I need your help, i'm stacked on this project. When i run my applicaion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.