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 8710905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:44:37+00:00 2026-06-13T04:44:37+00:00

I have some WCF service code that is virtually the same, except one method

  • 0

I have some WCF service code that is virtually the same, except one method is supposed to return a xml result, and the other a json result:

[ServiceContract]
public interface IRestServiceImpl
{
    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "xml/{id}")]
    string XMLData(string id);

    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "json/{id}")]
    string JSONData(string id);
}

The xml works fine (e.g., when I enter “http://localhost:4841/RestServiceImpl.svc/xml/2468” into the browser).

However, when I enter “http://localhost:4841/RestServiceImpl.svc/json/2468” I get a “File Download – Security Warning” dialog, which allows me to save a file (named “2468” in this case), which contains the following when opened in Notepad:

{“JSONDataResult”:”You requested product 2468″}

Is this “as-designed” (to save json results to a file), or why doesn’t it act the same way as the xml-o-rama?

  • 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-06-13T04:44:38+00:00Added an answer on June 13, 2026 at 4:44 am

    It’s up to your browser to determine how to handle any particular Content-Type, and it sounds like your browser doesn’t know what to do with JSON.

    To check this, while using the Chrome Dev Console or Firebug (or whatever equivalent in whatever browser you use), look at the network requests when you load that resource. In the headers, you should see something like

    Content-type: application/json
    

    If you do, the problem is your browser. If you don’t see that, your server or service code is wrong (and especially if it’s application/octet-stream which is the mime-type equivalent of “I have no idea”).

    As far as browser, personally I recommend Chrome + this excellent plugin for displaying formatted JSON output: https://github.com/callumlocke/json-formatter

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

Sidebar

Related Questions

I have a wcf service application that has some application startup code in the
I have inherited some code that queries a DB over a WCF service and
I have some special parameters to all my wcf service methods that are handled
I have a WCF service that is performing some updates across a couple of
I have a WCF service that processes some messages. I use EntityFramework to retrieve
I have the following code in a WCF Service that returns a string, and
I have some interface that is marked as a [ServiceContract] for WCF service. But
I have a WCF Web Service Framework 4 that exposes a very simple method
I have an Asp.Net application that calls some WCF service using a proxy generated
I now have the following code, which calls a WCF service, it get some

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.